Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Swap http => https for endpoint access, added Voulnet to contributers…

… in the README
  • Loading branch information...
commit aabd29a01ef649e76116d72d6f6504550e2e07d0 1 parent ca76271
Ryan McGrath authored
1  README.markdown
View
@@ -147,3 +147,4 @@ me and let me know (or just issue a pull request on GitHub, and leave a note abo
- **[Remy DeCausemaker (decause)](https://github.com/decause)**, PEP-8 contributions.
- **[mckellister](https://github.com/mckellister)**, Fixes to `Exception`s raised by Twython (Rate Limits, etc).
- **[tatz_tsuchiya](http://d.hatena.ne.jp/tatz_tsuchiya/20120115/1326623451)**, Fix for `lambda` scoping in key injection phase.
+- **[Voulnet (Mohammed ALDOUB)](https://github.com/Voulnet)**, Fixes for `http`/`https` access endpoints
10 README.txt
View
@@ -57,10 +57,9 @@ Streaming API
----------------------------------------------------------------------------------------------------
Twython, as of v1.5.0, now includes an experimental **[Twitter Streaming API](https://dev.twitter.com/docs/streaming-api)** handler.
Usage is as follows; it's designed to be open-ended enough that you can adapt it to higher-level (read: Twitter must give you access)
-streams. This also exists in large part (read: pretty much in full) thanks to the excellent **[python-requests](http://docs.python-requests.org/en/latest/) library by
+streams. This also exists in large part (read: pretty much in full) thanks to the excellent **[python-requests](http://docs.python-requests.org/en/latest/)** library by
Kenneth Reitz.
-
-**Example Usage:**
+
``` python
import json
from twython import Twython
@@ -77,7 +76,7 @@ Twython.stream({
'track': 'python'
}, on_results)
```
-
+
A note about the development of Twython (specifically, 1.3)
----------------------------------------------------------------------------------------------------
@@ -147,4 +146,5 @@ me and let me know (or just issue a pull request on GitHub, and leave a note abo
- **[Mesar Hameed (mhameed)](https://github.com/mhameed)**, Commit to swap `__getattr__` trick for a more debuggable solution.
- **[Remy DeCausemaker (decause)](https://github.com/decause)**, PEP-8 contributions.
- **[mckellister](https://github.com/mckellister)**, Fixes to `Exception`s raised by Twython (Rate Limits, etc).
-- **[tatz_tsuchiya](http://d.hatena.ne.jp/tatz_tsuchiya/20120115/1326623451), Fix for `lambda` scoping in key injection phase.
+- **[tatz_tsuchiya](http://d.hatena.ne.jp/tatz_tsuchiya/20120115/1326623451)**, Fix for `lambda` scoping in key injection phase.
+- **[Voulnet (Mohammed ALDOUB)](https://github.com/Voulnet)**, Fixes for `http`/`https` access endpoints
24 twython/twython.py
View
@@ -165,11 +165,11 @@ def __init__(self, twitter_token=None, twitter_secret=None, oauth_token=None, oa
OAuthHook.consumer_secret = twitter_secret
# Needed for hitting that there API.
- self.request_token_url = 'http://twitter.com/oauth/request_token'
- self.access_token_url = 'http://twitter.com/oauth/access_token'
- self.authorize_url = 'http://twitter.com/oauth/authorize'
- self.authenticate_url = 'http://twitter.com/oauth/authenticate'
- self.api_url = 'http://api.twitter.com/%s/'
+ self.request_token_url = 'https://twitter.com/oauth/request_token'
+ self.access_token_url = 'https://twitter.com/oauth/access_token'
+ self.authorize_url = 'https://twitter.com/oauth/authorize'
+ self.authenticate_url = 'https://twitter.com/oauth/authenticate'
+ self.api_url = 'https://api.twitter.com/%s/'
self.twitter_token = twitter_token
self.twitter_secret = twitter_secret
@@ -285,7 +285,7 @@ def request(self, endpoint, method='GET', params=None, version=1):
# In case they want to pass a full Twitter URL
# i.e. http://search.twitter.com/
- if endpoint.startswith('http://'):
+ if endpoint.startswith('http://') or endpoint.startwith('https://'):
url = endpoint
else:
url = '%s%s.json' % (self.api_url % version, endpoint)
@@ -424,7 +424,7 @@ def bulkUserLookup(self, ids=None, screen_names=None, version=1, **kwargs):
if screen_names:
kwargs['screen_name'] = ','.join(screen_names)
- lookupURL = Twython.constructApiURL("http://api.twitter.com/%d/users/lookup.json" % version, kwargs)
+ lookupURL = Twython.constructApiURL("https://api.twitter.com/%d/users/lookup.json" % version, kwargs)
try:
response = self.client.post(lookupURL, headers=self.headers)
return simplejson.loads(response.content.decode('utf-8'))
@@ -441,7 +441,7 @@ def search(self, **kwargs):
e.g x.search(q = "jjndf", page = '2')
"""
- searchURL = Twython.constructApiURL("http://search.twitter.com/search.json", kwargs)
+ searchURL = Twython.constructApiURL("https://search.twitter.com/search.json", kwargs)
try:
response = self.client.get(searchURL, headers=self.headers)
@@ -472,7 +472,7 @@ def searchGen(self, search_query, **kwargs):
e.g x.searchGen("python", page="2") or
x.searchGen(search_query = "python", page = "2")
"""
- searchURL = Twython.constructApiURL("http://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
+ searchURL = Twython.constructApiURL("https://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
try:
response = self.client.get(searchURL, headers=self.headers)
data = simplejson.loads(response.content.decode('utf-8'))
@@ -520,7 +520,7 @@ def isListMember(self, list_id, id, username, version=1):
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
try:
- response = self.client.get("http://api.twitter.com/%d/%s/%s/members/%s.json" % (version, username, list_id, id), headers=self.headers)
+ response = self.client.get("https://api.twitter.com/%d/%s/%s/members/%s.json" % (version, username, list_id, id), headers=self.headers)
return simplejson.loads(response.content.decode('utf-8'))
except RequestException, e:
raise TwythonError("isListMember() failed with a %d error code." % e.code, e.code)
@@ -539,7 +539,7 @@ def isListSubscriber(self, username, list_id, id, version=1):
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
try:
- response = self.client.get("http://api.twitter.com/%d/%s/%s/following/%s.json" % (version, username, list_id, id), headers=self.headers)
+ response = self.client.get("https://api.twitter.com/%d/%s/%s/following/%s.json" % (version, username, list_id, id), headers=self.headers)
return simplejson.loads(response.content.decode('utf-8'))
except RequestException, e:
raise TwythonError("isListMember() failed with a %d error code." % e.code, e.code)
@@ -662,7 +662,7 @@ def getProfileImageUrl(self, username, size=None, version=1):
size - Optional. Image size. Valid options include 'normal', 'mini' and 'bigger'. Defaults to 'normal' if not given.
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
- url = "http://api.twitter.com/%s/users/profile_image/%s.json" % (version, username)
+ url = "https://api.twitter.com/%s/users/profile_image/%s.json" % (version, username)
if size:
url = self.constructApiURL(url, {'size': size})
22 twython3k/twython.py
View
@@ -144,10 +144,10 @@ def __init__(self, twitter_token = None, twitter_secret = None, oauth_token = No
** Note: versioning is not currently used by search.twitter functions; when Twitter moves their junk, it'll be supported.
"""
# Needed for hitting that there API.
- self.request_token_url = 'http://twitter.com/oauth/request_token'
- self.access_token_url = 'http://twitter.com/oauth/access_token'
- self.authorize_url = 'http://twitter.com/oauth/authorize'
- self.authenticate_url = 'http://twitter.com/oauth/authenticate'
+ self.request_token_url = 'https://twitter.com/oauth/request_token'
+ self.access_token_url = 'https://twitter.com/oauth/access_token'
+ self.authorize_url = 'https://twitter.com/oauth/authorize'
+ self.authenticate_url = 'https://twitter.com/oauth/authenticate'
self.twitter_token = twitter_token
self.twitter_secret = twitter_secret
self.oauth_token = oauth_token
@@ -297,7 +297,7 @@ def bulkUserLookup(self, ids = None, screen_names = None, version = 1, **kwargs)
if screen_names:
kwargs['screen_name'] = ','.join(screen_names)
- lookupURL = Twython.constructApiURL("http://api.twitter.com/%d/users/lookup.json" % version, kwargs)
+ lookupURL = Twython.constructApiURL("https://api.twitter.com/%d/users/lookup.json" % version, kwargs)
try:
resp, content = self.client.request(lookupURL, "POST", headers = self.headers)
return simplejson.loads(content.decode('utf-8'))
@@ -314,7 +314,7 @@ def search(self, **kwargs):
e.g x.search(q = "jjndf", page = '2')
"""
- searchURL = Twython.constructApiURL("http://search.twitter.com/search.json", kwargs)
+ searchURL = Twython.constructApiURL("https://search.twitter.com/search.json", kwargs)
try:
resp, content = self.client.request(searchURL, "GET", headers = self.headers)
return simplejson.loads(content.decode('utf-8'))
@@ -337,7 +337,7 @@ def searchGen(self, search_query, **kwargs):
e.g x.searchGen("python", page="2") or
x.searchGen(search_query = "python", page = "2")
"""
- searchURL = Twython.constructApiURL("http://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
+ searchURL = Twython.constructApiURL("https://search.twitter.com/search.json?q=%s" % Twython.unicode2utf8(search_query), kwargs)
try:
resp, content = self.client.request(searchURL, "GET", headers = self.headers)
data = simplejson.loads(content.decode('utf-8'))
@@ -385,7 +385,7 @@ def isListMember(self, list_id, id, username, version = 1):
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
try:
- resp, content = self.client.request("http://api.twitter.com/%d/%s/%s/members/%s.json" % (version, username, list_id, repr(id)), headers = self.headers)
+ resp, content = self.client.request("https://api.twitter.com/%d/%s/%s/members/%s.json" % (version, username, list_id, repr(id)), headers = self.headers)
return simplejson.loads(content.decode('utf-8'))
except HTTPError as e:
raise TwythonError("isListMember() failed with a %d error code." % e.code, e.code)
@@ -404,7 +404,7 @@ def isListSubscriber(self, username, list_id, id, version = 1):
version (number) - Optional. API version to request. Entire Twython class defaults to 1, but you can override on a function-by-function or class basis - (version=2), etc.
"""
try:
- resp, content = self.client.request("http://api.twitter.com/%d/%s/%s/following/%s.json" % (version, username, list_id, repr(id)), headers = self.headers)
+ resp, content = self.client.request("https://api.twitter.com/%d/%s/%s/following/%s.json" % (version, username, list_id, repr(id)), headers = self.headers)
return simplejson.loads(content.decode('utf-8'))
except HTTPError as e:
raise TwythonError("isListMember() failed with a %d error code." % e.code, e.code)
@@ -426,7 +426,7 @@ def updateProfileBackgroundImage(self, filename, tile="true", version = 1):
fields = []
content_type, body = Twython.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}
- r = urllib.request.Request("http://api.twitter.com/%d/account/update_profile_background_image.json?tile=%s" % (version, tile), body, headers)
+ r = urllib.request.Request("https://api.twitter.com/%d/account/update_profile_background_image.json?tile=%s" % (version, tile), body, headers)
return urllib.request.urlopen(r).read()
except HTTPError as e:
raise TwythonError("updateProfileBackgroundImage() failed with a %d error code." % e.code, e.code)
@@ -445,7 +445,7 @@ def updateProfileImage(self, filename, version = 1):
fields = []
content_type, body = Twython.encode_multipart_formdata(fields, files)
headers = {'Content-Type': content_type, 'Content-Length': str(len(body))}
- r = urllib.request.Request("http://api.twitter.com/%d/account/update_profile_image.json" % version, body, headers)
+ r = urllib.request.Request("https://api.twitter.com/%d/account/update_profile_image.json" % version, body, headers)
return urllib.request.urlopen(r).read()
except HTTPError as e:
raise TwythonError("updateProfileImage() failed with a %d error code." % e.code, e.code)
Please sign in to comment.
Something went wrong with that request. Please try again.