我正嘗試在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