Skip to content
Browse files

Use a api proxy instead of the 'api.twitter.com/1/'... & Handle reque…

…st error.
  • Loading branch information...
1 parent 9f7287c commit 300ade354c10ac2ee6345d24ad1363a783e001be @ydoovv ydoovv committed Oct 18, 2010
Showing with 5 additions and 6 deletions.
  1. +5 −6 main.py
View
11 main.py
@@ -36,17 +36,16 @@ def get(self):
else:
page = self.request.get("p")
if page == "": page = "1"
- proxy = 'http://api.twitter.com/1/'
+ proxy = 'http://ydoovv.appspot.com/' # a twitter api proxy, or handle yourself
url = '%s/favorites/%s.json?page=%s' % (proxy, id_, page)
res = urlfetch.fetch(url)
favs = json.loads(res.content)
+ if isinstance(favs, dict): # {"request": "oooo", "error": "xxxx"}
+ self.response.out.write('%s}' % res.content.split(',')[0])
+ return
template_values = {"tweets": [], "id": id_, "page": int(page) + 1}
for fav in favs:
- if "text" not in fav:
- self.response.out.write("%s" % fav["error"])
- return
- else:
- tweet = fav["text"]
+ tweet = fav["text"]
urls = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', tweet)
url = ""
replaced_urls = {}

0 comments on commit 300ade3

Please sign in to comment.
Something went wrong with that request. Please try again.