Commit graph

457 commits

Author SHA1 Message Date
Ryan McGrath
6ebf6df884 Merge pull request #83 from Voulnet/patch-2
I fixed line 479 to properly URL encode the querystring (q parameter) fo...
2012-04-19 15:28:21 -07:00
Ryan McGrath
22fe97b432 Merge pull request #84 from Voulnet/patch-3
I have added the following lines to the function 'request' starting in l...
2012-04-19 15:26:53 -07:00
Mohammed ALDOUB
01a7284a8f I have added the following lines to the function 'request' starting in line 287:
# convert any http Twitter url into https, for the sake of user security
        # only convert the protocol part, not all occurences of http://, in case users want to search that
        endpoint = endpoint.replace('http://','https://',1)

This is to ensure all passed Twitter urls are converted into https, without messing with the rest of the url.
2012-04-14 05:53:51 +03:00
Mohammed ALDOUB
343dcb87ff I fixed line 479 to properly URL encode the querystring (q parameter) for the search functionality. According to http://dev.twitter.com/doc/get/search, the q parameter should be URL encoded, but Twython.unicode2utf8 doesn't urlencode the query.
So I enclosed it in a urllib.quote_plus function call.

examples: 

>>> urllib.quote_plus(Twython.unicode2utf8('h ^&$'))
'h+%5E%26%24'  
>>> Twython.unicode2utf8('h ^&$')
'h ^&$'
>>>
2012-04-14 05:34:22 +03:00
Michael Helmick
a42570b685 Trying to make this merge-able.
* We don't need RequestException anymore.

* I changed TwythonError to raise TwythonRateLimitError instead of
TwythonAPIError since TwythonRateLimitError is more verbose and in the
belief we should deprecate TwythonAPILimit and ultimately remove it in
2.0

* And I updated the version to 1.7.0 -- I feel like development as far
as versioning seems like it's going fast, but versioning is versioning
and I'm following Twitter's rhythm of versioning
<major>.<minor>.<bugfix>, minor changing when minor features or
significant fixes have been added. In this case, TwythonRateLimitError
should start being caught in place of TwythonAPILimit
2012-04-12 11:44:27 -04:00
Michael Helmick
3f26325ddb Updating methods to use internal get/post methods, updating methods using deprecated Twitter endpoints, updating some documentation on methods to start using rst format, plotting demise of deprecated Twython exceptiosn and methods >:)
* Updated all methods to use the internal get/post methods

* isListMember was using the deprecated *GET
:user/:list_id/members/:id* Twitter endpoint

* isListMember was also using a deprecated method

* Changed documentation on methods, the first line should be what the
method does (docstring)

* Started to change documentation for methods to use rst (restructed
text) -- What PyPi supports as well as Sphinx generator and others
instead of Markdown

* Planning to get rid of Exceptions - TwythonAPILimit, APILimit,
AuthError and Methods - searchTwitter(), searchTwitterGen()
2012-04-10 14:24:50 -04:00
Ryan McGrath
5a332a055e Merge pull request #76 from jvanasco/master
Changed the TwythonError to stash the error_code into self, one or two raises of TwythonError didn't pass in the status code, updated them to do so. (work by @jvanasco)
2012-04-10 08:35:41 -07:00
jonathan vanasco
9b798f7ac0 added error code tracking into the TwythonError 2012-04-10 10:21:00 -04:00
Ryan McGrath
ca76271127 Merge pull request #72 from michaelhelmick/dynamic_requests
Dynamic requests, moving towards 1.6.0.
2012-04-09 18:00:19 -07:00
Michael Helmick
813626a9ad Maybe the twitter_http_status_codes were a good idea. :P
I still think it's weird to have them, but I'm not against giving the
user more information. I put back in the twitter_http_status_codes
variable, but I changed where the logic was being handled, instead of
it happening the in _request, it will be asserted in Twython error if
an error_code is passed AND the error_code is in
twitter_http_status_codes
2012-04-09 10:59:13 -04:00
Michael Helmick
eb22296e33 Merged dynamic_requests with recent pull request additions
* Removed twitter_http_status_codes. Unnecessary variable when we are
giving them the error back.

* Added a "Please see..." message to TwythonError if the exception
passes an error code, linking to Twitter API error response page.

* Merged stuff from constructFunc into _request()
2012-04-09 10:49:44 -04:00
Ryan McGrath
4042407970 Merge pull request #74 from jvanasco/master
Enhanced debugging support courtesy of jvanasco.
2012-04-08 17:29:06 -07:00
Ryan McGrath
515e94c994 Merge pull request #73 from eriks5/master
oauth_callback_url cleanup
2012-04-08 17:20:47 -07:00
jonathan vanasco
59b0386564 Several improvements to allow for debugging , error handling :
- added twitter's http status codes to twitter_endpoints.py ( dict index on status code, value is a tuple of name + description )
- created an internal stash called '_last_call' that stores details of the last api call ( the call, response data, headers, url, etc )
- better error handling for api issues:
- - raises an error when the status code is not 200 or 304
- - raises TwythonAPILimit when a 420 rate limit code is returned
- - raises a TwythonError on other issues, setting the correct status code and using messages that are from the twitter API
- wraps a successful read in a try/except block.  there's an error i haven't been able to reproduce where invalid content can get in there, it would be nice to catch it and write a handler for it.  ( the previous functions were all introducted to allow this to be debugged )
- added a 'get_lastfunction_header' method. if the API has not been called yet , raises a TwythonError.  otherwise it attempts to return the header value twitter last sent.  useful for x-ratelimit-limit , x-ratelimit-remaining , x-ratelimit-class , x-ratelimit-reset
2012-04-08 18:37:47 -04:00
Michael Helmick
7205aa402a Get rid of print 2012-04-06 14:19:46 -04:00
Erik
e353125ef1 Removed 'import inspect' as it is no longer needed. 2012-04-06 18:48:26 +02:00
Michael Helmick
703012ef29 Use simplejson if they have it first, allow for version passing in generic requests, catch json decoding errors and status code errors
* Changed the importing order for simplejson, if they have the library
installed, chances are they're going to want to use that over Python
json, json is slower than simplejson

* Version passing is now avaliable

* Catching json decode errors (ValueError) and Twitter Errors on
`_request` method and returning content rather than the response object.
2012-04-06 11:44:30 -04:00
Erik
ffb768d24d Fix adding callback_url for old style servers 2012-04-06 11:09:43 +02:00
Erik
f4c00ff996 If callback_url is not set, don't force it to 'oob' 2012-04-06 11:08:12 +02:00
Erik
e17b3ed877 Removed OAuth library callback_url detection code, as callback_url passing does not depend on that anymore. 2012-04-06 11:02:11 +02:00
Michael Helmick
0fcd4202c8 Whoops.. didn't mean to give those out. Haha. 2012-03-31 20:18:12 -04:00
Michael Helmick
cf38c7c3de POSTing works again, somehow it broke... :/ 2012-03-31 20:16:30 -04:00
Michael Helmick
03f3a22480 Dynamic Request Methods
Just in case Twitter releases something in their API and a developer
wants to implement it on their app, but we haven't gotten around to
putting it in Twython yet. :)
2012-03-31 18:12:07 -04:00
Ryan McGrath
9153fdf41b Merge pull request #70 from michaelhelmick/master
Passing kwargs to function now works. Urgent bug fix.
2012-03-23 18:42:50 -07:00
Michael Helmick
23e529e167 Passing params through functions now work, bug fix version bump
For example:
Twython.getHomeTimeline(include_rts=True) was failing. Really sorry
about this. It is now fixed.
2012-03-23 15:46:19 -04:00
Ryan McGrath
861c05718d Merge pull request #69 from michaelhelmick/master
Dynamic callback url works again, PEP8 clean up
2012-03-21 12:43:16 -07:00
Michael Helmick
59b5733a86 Version Number 2012-03-21 15:27:13 -04:00
Michael Helmick
f917b6bfea PEP8 Clean up
A couple variables were wrong. Somewhere was using 'r' when 'request'
was the correct variable

Somewhere was using json.loads and not simplejson.loads
2012-03-21 15:25:25 -04:00
Michael Helmick
5eb7f29bff Dynamic Callback URL works again
Using POST to set dynamic callback_url decided to break within 3 hours
of testing it.. haha.
2012-03-21 15:19:27 -04:00
Ryan McGrath
8e26e568a6 README formatting 2012-03-21 19:37:37 +01:00
Ryan McGrath
87c1f1e71c README formatting 2012-03-21 19:36:33 +01:00
Ryan McGrath
16a70d0240 README formatting 2012-03-21 19:35:35 +01:00
Ryan McGrath
6d72b8aa33 Mmmm fix this...? 2012-03-21 19:34:32 +01:00
Ryan McGrath
e0c76501ba Note about new Streaming API stuff 2012-03-21 19:32:25 +01:00
Ryan McGrath
9deced8f8b v1.5.0 release
- requests is now the default url/http library, thanks to Mike Helmick
- Initial pass at a Streaming API is now included (Twython.stream()), due to how easy
    requests makes it. Would actually be sad if we *didn't* have this... thanks, Kenneth. >_>;
- Return of shortenURL, for people who may have relied on it before.
- Deleted streaming handler that existed before but never got implemented fully.
- Exceptions now prefixed with Twython, but brought back originals with a more verbose error directing
    people to new ones, deprecate fully in future.
- Twython3k now has an OAuth fix for callback_urls, though it still relies on httplib2. Thanks @jbouvier!
- Added a list of contributors to the README files, something which I should have done long ago. Thank you all.
2012-03-21 19:21:34 +01:00
Ryan McGrath
1a6852de54 Merge pull request #68 from michaelhelmick/master
Dynamic callback url, combo jbouvier/michaelhelmick.
2012-03-21 09:04:14 -07:00
Michael Helmick
9e8bc09121 Fixes #67
Dynamic callback url
2012-03-21 11:41:27 -04:00
Ryan McGrath
55b6396a60 Merge pull request #65 from michaelhelmick/implement_requests
Implement requests (BETA, report bugs if you find them please)
2012-03-18 06:56:35 -07:00
Michael Helmick
158bf77231 Remove httplib2 dependency, remove "shortenUrl" function, no need for urllib2 either
* Removed shortenUrl since Twitter ALWAYS shortens the URL to a t.co,
anyways.

* Since removing shortenUrl, no need for urllib2 anymore

* No need for httplib2 anymore, either
2012-03-08 12:24:03 -05:00
Michael Helmick
8630dc3f03 Twython using requests/requests-oauth 2012-03-08 12:20:04 -05:00
Michael Helmick
e3d9ed656b PEP8 Cleanup on Twitter Endpoints 2012-03-06 16:58:27 -05:00
Ryan McGrath
5cd1129098 Merge pull request #62 from michaelhelmick/pep8_and_verboseness
- Exceptions now prefixed with "Twython", change your code accordingly
- PEP8 Cleanup
- Removed unused libraries and dependencies
2012-03-03 16:48:50 -08:00
Michael Helmick
2f749183ab PEP8 Cleanup, More Verbosness
* Rid of a lot of libs not being used
* Changing Exceptions to prefix with "Twython", just safer in case
other apps have "AuthError", etc. for some reason.
2012-02-28 15:16:39 -05:00
Ryan McGrath
449a71daf8 Merge pull request #57 from LuqueDaniel/master
Extended example
2012-02-23 13:25:48 -08:00
Daniel
bb99c90f1a Extended example 2012-02-23 21:13:08 +01:00
Ryan McGrath
eca965715e 1.4.6 release for bug fixes - upgrade, please 2012-01-15 14:07:04 -05:00
Ryan McGrath
a4334bb67d Somewhat bring 3k up to par; currently way behind, will fix after finishing Requests merge 2012-01-15 14:06:37 -05:00
Ryan McGrath
fcbc702ae5 Fixes an issue in the 1.4.5 point release, first pointed out by @michaelhelmick, fixed thanks to "tatz_tsuchiya". 2012-01-15 13:59:28 -05:00
Ryan McGrath
ae5e63150b Merge pull request #56 from michaelhelmick/status_with_media
Generic _media_update() func., added func. to update status with a photo...
2012-01-14 05:27:56 -08:00
Michael Helmick
401f610be5 Generic _media_update() func., added func. to update status with a photo.
* Generic _media_update() func. for the 3 media api calls

* Added func. to update status with a photo. updateStatusWithMedia()
2012-01-13 16:25:52 -05:00