Tango now supports adding a unique User Agent, in keeping with Twitter's Search API requirements. See the Wiki for information on usage.
This commit is contained in:
parent
8bf063fdf9
commit
4fed1e241f
2 changed files with 13 additions and 12 deletions
6
tango.py
6
tango.py
|
|
@ -15,7 +15,7 @@ import httplib, urllib, urllib2, mimetypes, mimetools
|
|||
from urllib2 import HTTPError
|
||||
|
||||
__author__ = "Ryan McGrath <ryan@venodesigns.net>"
|
||||
__version__ = "0.5"
|
||||
__version__ = "0.6"
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
|
|
@ -45,7 +45,7 @@ class APILimit(TangoError):
|
|||
return repr(self.msg)
|
||||
|
||||
class setup:
|
||||
def __init__(self, authtype = "OAuth", username = None, password = None, oauth_keys = None):
|
||||
def __init__(self, authtype = "OAuth", username = None, password = None, oauth_keys = None, headers = None):
|
||||
self.authtype = authtype
|
||||
self.authenticated = False
|
||||
self.username = username
|
||||
|
|
@ -63,6 +63,8 @@ class setup:
|
|||
self.auth_manager.add_password(None, "http://twitter.com", self.username, self.password)
|
||||
self.handler = urllib2.HTTPBasicAuthHandler(self.auth_manager)
|
||||
self.opener = urllib2.build_opener(self.handler)
|
||||
if self.headers is not None:
|
||||
self.opener.addheaders = [('User-agent', self.headers)]
|
||||
try:
|
||||
test_verify = simplejson.load(self.opener.open("http://twitter.com/account/verify_credentials.json"))
|
||||
self.authenticated = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue