我正尝试在Google应用引擎项目中使用pyfacebook函数(https://github.com/sciyoshi/pyfacebook/)。我遵循Facebook开发者论坛上的建议(http://forum.developers.facebook.net/viewtopic.php?pid=164613)并将其他函数添加到__init__.py文件中,将该文件复制到根目录我的项目目录并将其重命名为facebook.py。已经进口facebook.py添加以下的get(个体经营)方法的Python类的页:pyfacebook + Google App Engine:在facebook.py中找不到新功能
facebookapi = facebook.Facebook(API_KEY, SECRET)
if not facebookapi.check_connect_session(self.request):
path = os.path.join(os.path.dirname(__file__), 'templates/login.html')
self.response.out.write(template.render(path, {'apikey': API_KEY}))
return
user = facebookapi.users.getInfo(
[facebookapi.uid],
['uid', 'name', 'birthday', 'relationship_status'])[0]
template_values = {
'name': user['name'],
'birthday': user['birthday'],
'relationship_status': user['relationship_status'],
'uid': user['uid'],
'apikey': API_KEY
}
path = os.path.join(os.path.dirname(__file__), 'templates/index.html')
self.response.out.write(template.render(path, template_values))
当运行它,我得到以下错误:
File "\much\baw08u\Private\IDS\helloworld\helloworld.py", line 54, in get
if not facebookapi.check_connect_session(self.request): AttributeError: 'Facebook' object has no attribute 'check_connect_session'
如此看来要加载facebook API的罚款,但不是我添加的新方法。我复制并粘贴了Facebook类定义底部的开发者论坛中的代码,并确保所有缩进都是正确的,但它似乎仍然没有被选中。有谁知道可能是什么问题?
感谢
本
你是否已经将方法添加到Facebook.Facebook(应该工作)或功能到Facebook(不应该工作,除非你使用facebook.function_name)? – TryPyPy 2011-01-26 16:06:18
是的,这一切都在facebook.Facebook - 检查缩进和一切。有没有人有修改的\ __ init__.py的副本,我可以测试以查看它是否与语法有关? – benwad 2011-01-27 12:29:29