我在 facebook javascript SDK 和 python requesthandler 变量之间得到了冲突的结果。 Javascript SDK 表示我的用户未登录,这是正确的,而来自基本请求处理程序的模板变量表示我的用户已登录并显示用户名。是否有足够的信息来说明问题所在,或者我应该在此处粘贴我认为相关的代码?出现错误的登录页面的链接是here http://www.koolbusiness.com/login。我使用的示例称为 facebook 的 runwithfriends 演示应用程序,该应用程序的所有功能都可以正常工作,除了仅使用来自网站的应用程序逻辑而不要求用户位于应用程序的 iframe 中。
另外,我似乎无法让实时 API 工作。我只能保存用户 ID 而不能刷新用户数据 - 为什么?我有代码,但我不确定什么是最相关的,但这是一些请求处理程序,相关代码基本上与演示应用程序中的代码完全相同:
def render(self, name, **data):
logging.debug('render')
"""Render a template"""
if not data:
logging.debug('no data')
data = {}
data[u'js_conf'] = json.dumps({
u'appId': facebookconf.FACEBOOK_APP_ID,
u'canvasName': facebookconf.FACEBOOK_CANVAS_NAME,
u'userIdOnServer': self.user.id if self.user else None,
})
data[u'logged_in_user'] = self.user #variable that is the problem
data[u'message'] = self.get_message()
data[u'csrf_token'] = self.csrf_token
data[u'canvas_name'] = facebookconf.FACEBOOK_CANVAS_NAME
self.response.out.write(template.render(
os.path.join(
os.path.dirname(__file__), 'templates', name + '.html'),
data))
And even more strange, I can also get the application in a state where the javascript SDK says the user is logged in and the template variable logged_in_user
says otherwise. Why are the variables conflicting?
Update: Here are screenshots from the strange login flow. I can go to my page and my name from facebook appears:
Then when I go to next page it also looks alright and has my name
But if I log out then I gets in impossible state: my name + logged out
How can I resolve this strange conflict between js and back-end?
更新:由于我只在我的一个应用程序中遇到此问题,因此我可以从其他应用程序中获取有效的内容并进行集成。该页面似乎可以在我的其他应用程序中使用:http://cyberfaze.appspot.com/file/20985 http://cyberfaze.appspot.com/file/20985