使用pyfacebook更新Facebook页面的状态 [英] Update Facebook Page's status using pyfacebook

查看:126
本文介绍了使用pyfacebook更新Facebook页面的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试添加功能到我的Django应用程序:当一个新的帖子被批准,我想更新相应的Facebook页面的状态,一个消息和一个链接自动发布。基本状态更新。



我已经下载并安装了 pyfacebook - 我已经阅读了教程从Facebook。我也看到这个建议这里是SO

  import facebook 
fb = facebook.Facebook('YOUR_API_KEY','YOUR_SECRET_KEY')
fb.auth.createToken )
fb.login()#这是我可以获得
fb.auth.getSession()
fb.set_status('检出StackOverFlow.com')

然而,当我访问 login() pyfacebook试图打开lynx,所以我可以通过网络登录到Facebook' - 这显然不会为我工作,因为系统应该是自动化的...
我一直在寻找,但是找不到如何保持这一切都可以使用脚本,而不必通过网络浏览器进行登录。



任何想法?

解决方案

login ,特别是在docstring中,似乎打算使用浏览器,以便您以这种方式登录。

  def login(self,popup = False):
打开一个Web浏览器,告诉用户登录到Facebook。
import webbrowser
webbrowser.open(self.get_login_url(popup = popup))

您链接的Facebook页面用户:PyFacebook_Tutorial ,它看起来像例如 login 是一个桌面应用程序示例。您要遵循Web应用程序部分。我鼓励你直接按照那里的教程。


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?

解决方案

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.

def login(self, popup=False):
    """Open a web browser telling the user to login to Facebook."""
    import webbrowser
    webbrowser.open(self.get_login_url(popup=popup))

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.

这篇关于使用pyfacebook更新Facebook页面的状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆