Python 将SELF.PATH与新的Facebook URL返回一起使用

Python 将SELF.PATH与新的Facebook URL返回一起使用,python,flask,Python,Flask,我使用以下代码:从Facebook获取图形文件 事实上,它在很长一段时间内都很有效。但是突然之间,自我路径就不再有效了?在我看来,self.path是空的 编辑:好吧,经过一些研究,我发现Facebook实际上改变了他们返回url的方式 他们返回的url如下所示:http://xxxxxx:8000/?accesstoken= 但现在他们改为:http://xxxxxx:8000/?accesstoken= 现在self.path不可用,因为它不理解 有什么建议吗 它在中失败,我得到以下错误:

我使用以下代码:从Facebook获取图形文件

事实上,它在很长一段时间内都很有效。但是突然之间,自我路径就不再有效了?在我看来,self.path是空的

编辑:好吧,经过一些研究,我发现Facebook实际上改变了他们返回url的方式

他们返回的url如下所示:http://xxxxxx:8000/?accesstoken=

但现在他们改为:http://xxxxxx:8000/?accesstoken=

现在self.path不可用,因为它不理解

有什么建议吗

它在中失败,我得到以下错误:

127.0.0.1 - - [16/Oct/2013 11:21:36] "GET /? HTTP/1.1" 200 -
Traceback (most recent call last):
  File "/Users/Eskil/Downloads/Facebook-Friend-Graph-master/src/2.7/main.py", line 49, in main
    access_token = get_access_token(app_id)
  File "/Users/Eskil/Downloads/Facebook-Friend-Graph-master/src/2.7/accesstoken.py", line 122, in get_access_token
    raise Exception(httpd.error)
Exception: unknown error: {}
因此,失败的代码位于accesstoken.py中:

def do_GETself: 此方法从Facebook中提取访问令牌或错误 用户登录或取消Facebook身份验证后的请求 self.send_响应200 self.send_标题'Content-type','text/html' self.end\u头文件

self.server.access_token = ""
self.server.error = ""

if '?' in self.path:
    query = urlparse.parse_qs(urlparse.urlparse(self.path)[4])
    if query.has_key('access_token'):
        self.server.access_token = query['access_token'][0]
        self.wfile.write(html % ('Thank You!', 'You may now close this tab.'))
    else:
        self.server.error = query.get('error_reason', ['unknown error: %s' % str(query)])[0]
        if self.server.error == 'user_denied':
            self.wfile.write(html % ('Error', 'You must login to Facebook for the software to work.<br/>' +
                'This software does not store any user names or passwords.'))
        else:
            self.wfile.write(html % ('Error', 'Sorry! An error has occurred. Please try again.'))
else:
    self.wfile.write(html % ('Redirect', javascript_redirect))

self路径无法从URL获取accesstoken,因为URL中突然出现了一个问题,我猜下面的代码可能是问题的原因

我对facebook graph一无所知,但上面的代码表示URL中的每个实例都替换为“?”。因此,URL现在将变为以下内容

http://whateversite:8000/??accesstoken= (notice the consecutive ??)
因此,它正在创建一个空白查询字符串,可能是?

修复了它,将其从self.path中的if'?'更改而来

到self.path中的if“token”

这样,它将进入if else中的最后一个陡坡,并替换为


还将顶部的javascrit更改为window.location=url.replace,删除了

是否可以修改您的问题并包含失败代码的代码示例?最好是a。当您指定指向整个代码库的链接并说我正在尝试使用它时,这是非常困难的。事实上它没有。请参阅self.path:中的if循环:if'?',如果它没有找到?然后它将替换为?
http://whateversite:8000/??accesstoken= (notice the consecutive ??)