I'm having problems getting data from the Twitter search API with Google App Engine. Working in the personal development environment I have no problems. I'm able to get the JSON I want. However, once the code gets deployed to App Engine, I encounter a HTTP 500 Error Code.
The only ideas I have for whats going on is that there is some fundamental difference between the dev and live App Engine environments that I'm missing and/or that Twitter is refusing requests from the App Engine IP I'm running from. I wrote a small @app.route to absolutely verify that there are issues - is is below.
I'm pretty sure I'm not hitting a rate limit because the Twitter Search API doesn't explicitly have one. I saw that they requested a user-agent so I've been providing that but I'm still getting the same 500 Error.
The live version of what I'm working with is here: http://1-alpha-3.rich90usa.appspot.com/twitter_test
Any thoughts on what's going wrong here would be greatly appreciated.
Relevant Section from Flask:
@app.route('/twitter_test')
def twitter_test():
twitter_geo_url = 'http://search.twitter.com/search.json?callback=?&rpp=100&geocode=29.6516344,-82.3248262,3mi'
twitter_result = urlfetch.fetch(twitter_geo_url, fetch_headers)
if twitter_result.status_code == 200:
return twitter_result.content
Where 'fetch_headers' is previously defined as:
fetch_headers = {'User-Agent': "APPNAME-1-alpha-3"}
Top of my Flask py file:
from flask import Flask, request, render_template, session, redirect
import oauth2 as oauth
import simplejson as json
import urlparse
import urllib
import httplib
import time
from google.appengine.api import urlfetch