Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python cgi.parse_qsl导致GAE出现奇怪错误_Python_Google App Engine_Cgi - Fatal编程技术网

Python cgi.parse_qsl导致GAE出现奇怪错误

Python cgi.parse_qsl导致GAE出现奇怪错误,python,google-app-engine,cgi,Python,Google App Engine,Cgi,我希望使用GAE构建一个facebook应用程序。下面的代码 from google.appengine.ext.webapp.util import run_wsgi_app from google.appengine.ext import webapp from urllib import urlopen, quote import cgi from django.utils import simplejson as json class fbcheck(webapp.Reque

我希望使用GAE构建一个facebook应用程序。下面的代码

    from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import webapp

from urllib import urlopen, quote
import cgi
from django.utils import simplejson as json

class fbcheck(webapp.RequestHandler):
    def get(self):
        appid = 'XXX'
        appsecret = 'XXXX'
        myurl = 'XXX'

        code = self.request.get("code")
        if not code :
            dialogurl = 'https://facebook.com/dialog/outh?client_id=%s&redirect_uri=%s'%(appid,quote(myurl))
            self.response.out.write('<script> top.location.href="%s"</script>'%(dialogurl,))
        tokenurl = 'https://graph.facebook.com/oauth/access_token?client_id=%s&redirect_uri=%s&client_secret=%s&code=%s'%(appid,quote(myurl),appsecret,code)
        response = cgi.parse_qsl(urlopen(tokenurl))
        graphurl = 'https://graph.facebook.com/me?access_token=%s'%(response['access_token'],)
        user = json.loads(urlopen(graphurl))
        self.response.out.write('Hi %s'(user.name,))
        #self.response.out.write('hi')

application = webapp.WSGIApplication([('/', fbcheck),], debug=True)
def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()

对同一问题的任何建议都应该是
response=cgi.parse_qsl(urlopen(tokenurl.read())
;urlopen返回类
AddInfo URL
的实例,该实例可以从中读取,而不是URL的内容。

得到它。它应该是response=cgi.parse_qsl(urlopen(tokenurl.read())将您的评论作为答案发布!
    Traceback (most recent call last):
  File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 700, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/s~dotsnboxes/1.351361343827624192/game.py", line 22, in get
    response = cgi.parse_qsl(urlopen(tokenurl))
  File "/base/python_runtime/python_dist/lib/python2.5/cgi.py", line 213, in parse_qsl
    pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
AttributeError: addinfourl instance has no attribute 'split'