PyFacebook:Facebook() 实例没有流方法
我需要在 django 应用程序中更新我的 Facebook 粉丝页面,因此我有以下代码:
import facebook
from django.conf import settings
def login_facebook():
fb = facebook.Facebook(settings.FACEBOOK_API_KEY, settings.FACEBOOK_SECRET_KEY)
fb.session_key = settings.FACEBOOK_SESSION
fb.secret = settings.FACEBOOK_SECRET_KEY
fb.uid = settings.FACEBOOK_UID
return fb
def update_status(fb, message):
return fb.stream.publish(message=status_message)
我用它来通过 ipython 运行它:
import src.tests.scripts.facebook_publish_fanpage as f
fb = f.login_facebook()
f.update_status(fb, 'This is a test')
但我得到了这个异常:
AttributeError: 'Facebook' object has no attribute 'stream'
我已经按照以下 2 个步骤向应用程序授予了权限:
在 Facebook 页面上发布帖子(1) 并授权 Facebook 粉丝页面进行状态更新(2)
但无论我尝试什么(现在已经做了几个小时...)我无法发布到该页面...
我现在迷路了,有什么帮助吗?
(1) tech.karolzielinski.com/publish-post-of-facebook-page-wall-as-a-page-not-a-user-python-facebook-rest-api
(2) stackoverflow.com/questions/2097665 /authorizing-a-facebook-fan-page-for-status-updates
PD:抱歉,还没有添加链接的权限,我主要是 SO 的读者
I need to update my Facebook Fan Page in a django app so I have this code:
import facebook
from django.conf import settings
def login_facebook():
fb = facebook.Facebook(settings.FACEBOOK_API_KEY, settings.FACEBOOK_SECRET_KEY)
fb.session_key = settings.FACEBOOK_SESSION
fb.secret = settings.FACEBOOK_SECRET_KEY
fb.uid = settings.FACEBOOK_UID
return fb
def update_status(fb, message):
return fb.stream.publish(message=status_message)
And I use this to run it with ipython:
import src.tests.scripts.facebook_publish_fanpage as f
fb = f.login_facebook()
f.update_status(fb, 'This is a test')
But I get this exception:
AttributeError: 'Facebook' object has no attribute 'stream'
I already gave permissions to the app following this 2 steps:
Publish post on Facebook page(1) and Authorizing a Facebook Fan Page for Status Updates(2)
But no matter what I try (being doing it a few hours now...) I can't publish to the page...
I'm lost now, any help?
(1) tech.karolzielinski.com/publish-post-of-facebook-page-wall-as-a-page-not-a-user-python-facebook-rest-api
(2) stackoverflow.com/questions/2097665/authorizing-a-facebook-fan-page-for-status-updates
PD: Sorry don't have permission to add the links yet, I'm mostly a reader in SO
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过几个小时的搜索后,我终于找到了解决方案...不使用流方法,而是这样:
在此博客文章中找到了解决方案: http://danielquinn.org/blog/1578.html
有效!
After searching for hours I finally found the solution... not to use stream methods but this:
Found the solution at this blog post: http://danielquinn.org/blog/1578.html
That works!!