使用 pyfacebook 更新 Facebook 页面的状态
我正在尝试向我的 Django 应用程序添加功能:当新帖子获得批准时,我想使用消息和帖子链接自动更新相应的 Facebook 页面的状态。基本状态更新。
我已经下载并安装了 pyfacebook - 并且我已通读来自 Facebook 的教程。我也看到了这个建议这里:
import facebook
fb = facebook.Facebook('YOUR_API_KEY', 'YOUR_SECRET_KEY')
fb.auth.createToken()
fb.login() # THIS IS AS FAR AS I CAN GET
fb.auth.getSession()
fb.set_status('Checking out StackOverFlow.com')
当我到达然而,login()
调用,pyfacebook 尝试打开 lynx,以便我可以“通过网络”登录 Facebook——显然,这对我不起作用,因为系统应该自动化... 我一直在寻找,但不知道如何让这一切与脚本一起工作,而不必通过网络浏览器登录。
有什么想法吗?
I am attempting to add functionality to my Django app: when a new post is approved, I want to update the corresponding Facebook Page's status with a message and a link to the post automatically. Basic status update.
I have downloaded and installed pyfacebook - and I have read through the tutorial from Facebook. I have also seen this suggestion here on SO:
import facebook
fb = facebook.Facebook('YOUR_API_KEY', 'YOUR_SECRET_KEY')
fb.auth.createToken()
fb.login() # THIS IS AS FAR AS I CAN GET
fb.auth.getSession()
fb.set_status('Checking out StackOverFlow.com')
When I get to the login()
call, however, pyfacebook tries to open lynx so I can login to Facebook 'via the web' -- this is, obviously, not going to work for me because the system is supposed to be automated ...
I've been looking, but can't find out how I can keep this all working with the script and not having to login via a web browser.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在
login
的定义中,特别是在文档字符串中,似乎预期的行为是打开浏览器以便让您以这种方式登录。查看您链接的 Facebook 页面 User:PyFacebook_Tutorial,看起来就像
login
的示例是一个“桌面应用程序”示例。您想要遵循“Web 应用程序”部分。我鼓励您继续阅读那里的教程。In the definition of
login
, particularly in the docstring, it appears as though the intended behavior is to open up a browser in order to have you log in that way.Looking at the facebook page User:PyFacebook_Tutorial that you linked, it looks like the example with
login
is a "Desktop Applications" example. You want to follow the "Web Applications" section. I'd encourage you to simply press ahead with the tutorial there.如果您想登录您的 Facebook 个人资料页面,我已经设法使用此脚本来完成此操作:
将此文件另存为 fb_login.py 并在同一文件夹中创建一个文件 fb_test.html
我已成功登录,您可以通过在浏览器上查看 fb_test.html 或在纯文本中搜索您的姓名来证明。
有谁知道如何使用简单的身份验证凭据登录,而不是使用申请所需的秘密和 API 密钥登录?
If you want to login to your facebook profile page I have managed to do it with this script:
Save this file as fb_login.py and in the same folder create a file fb_test.html
I successfully logged in as you can prove by viewing on your browser the fb_test.html or searching for your name in the plain text.
Does anyone knows how to login with simple Authedication credentials and not with SECRET AND API key that you need to make application?