The final API method, Saved Searches. Fixed an issue with the Direct Message function where urllib.urlencode wasn't formed properly; only thing left for release is OAuth.
This commit is contained in:
parent
9e1159dd6f
commit
90d7e5ffb0
1 changed files with 45 additions and 1 deletions
46
tango.py
46
tango.py
|
|
@ -216,7 +216,7 @@ class setup:
|
||||||
if self.authenticated is True:
|
if self.authenticated is True:
|
||||||
if len(list(text)) < 140:
|
if len(list(text)) < 140:
|
||||||
try:
|
try:
|
||||||
return self.opener.open("http://twitter.com/direct_messages/new.json", urllib.urlencode({"user": user, "text" text}))
|
return self.opener.open("http://twitter.com/direct_messages/new.json", urllib.urlencode({"user": user, "text": text}))
|
||||||
except HTTPError, e:
|
except HTTPError, e:
|
||||||
if self.debug is True:
|
if self.debug is True:
|
||||||
print e.headers
|
print e.headers
|
||||||
|
|
@ -579,6 +579,50 @@ class setup:
|
||||||
print e.headers
|
print e.headers
|
||||||
print "getWeeklyTrends() failed with a " + str(e.code) + " error code."
|
print "getWeeklyTrends() failed with a " + str(e.code) + " error code."
|
||||||
|
|
||||||
|
def getSavedSearches(self):
|
||||||
|
if self.authenticated is True:
|
||||||
|
try:
|
||||||
|
return simplejson.load(self.opener.open("http://twitter.com/saved_searches.json"))
|
||||||
|
except HTTPError, e:
|
||||||
|
if self.debug is True:
|
||||||
|
print e.headers
|
||||||
|
print "getSavedSearches() failed with a " + str(e.code) + " error code."
|
||||||
|
else:
|
||||||
|
print "getSavedSearches() requires you to be authenticated."
|
||||||
|
|
||||||
|
def showSavedSearch(self, id):
|
||||||
|
if self.authenticated is True:
|
||||||
|
try:
|
||||||
|
return simplejson.load(self.opener.open("http://twitter.com/saved_searches/show/" + id + ".json"))
|
||||||
|
except HTTPError, e:
|
||||||
|
if self.debug is True:
|
||||||
|
print e.headers
|
||||||
|
print "showSavedSearch() failed with a " + str(e.code) + " error code."
|
||||||
|
else:
|
||||||
|
print "showSavedSearch() requires you to be authenticated."
|
||||||
|
|
||||||
|
def createSavedSearch(self, query):
|
||||||
|
if self.authenticated is True:
|
||||||
|
try:
|
||||||
|
return simplejson.load(self.opener.open("http://twitter.com/saved_searches/create.json?query=" + query, ""))
|
||||||
|
except HTTPError, e:
|
||||||
|
if self.debug is True:
|
||||||
|
print e.headers
|
||||||
|
print "createSavedSearch() failed with a " + str(e.code) + " error code."
|
||||||
|
else:
|
||||||
|
print "createSavedSearch() requires you to be authenticated."
|
||||||
|
|
||||||
|
def destroySavedSearch(self, id):
|
||||||
|
if self.authenticated is True:
|
||||||
|
try:
|
||||||
|
return simplejson.load(self.opener.open("http://twitter.com/saved_searches/destroy/" + id + ".json", ""))
|
||||||
|
except HTTPError, e:
|
||||||
|
if self.debug is True:
|
||||||
|
print e.headers
|
||||||
|
print "destroySavedSearch() failed with a " + str(e.code) + " error code."
|
||||||
|
else:
|
||||||
|
print "destroySavedSearch() requires you to be authenticated."
|
||||||
|
|
||||||
# The following methods are apart from the other Account methods, because they rely on a whole multipart-data posting function set.
|
# The following methods are apart from the other Account methods, because they rely on a whole multipart-data posting function set.
|
||||||
def updateProfileBackgroundImage(self, filename, tile="true"):
|
def updateProfileBackgroundImage(self, filename, tile="true"):
|
||||||
if self.authenticated is True:
|
if self.authenticated is True:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue