使用Python自动发布到Facebook页面
我想制作一个脚本,让我可以发布到我的 facebook 粉丝页面(我是该页面的管理员)
据我所知,大多数图形 api 示例都是关于用 python 制作 facebook 应用程序并让它们与 python 进行通信,这与我想要的完全不同。
此外,图形 api 需要 oauth 令牌,文档声称它是通过执行以下操作获得的:
https://www.facebook .com/dialog/oauth? client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
我认为这意味着:
a)我必须为此创建一个 facebook 应用程序,我认为没有必要(毕竟它只需要我的标准凭据,并且不会被其他人使用),但没关系。我为此任务创建了一个应用程序。
b) 我需要一个 URL,但我没有,因为它只是一个脚本。
关于我应该在哪里寻找一些信息有什么想法吗?
I want to make a script that lets me post to my facebook fan page (which I'm an admin of)
As far as I've seen, Most graph api examples are about making facebook apps in python and make them communicate with python, which is quite different from what I want.
Also The graph api requires the oauth token, which the documentation claims it's obtained by doing:
https://www.facebook.com/dialog/oauth?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL
I think this implies:
a) I HAVE to create a facebook app for this, which I didn't think it was necessary (after all it's something that would require only my standard credentials and wouldn't be used by other people), but it is fine. I have an app created for this task.
b) I need an URL, which I don't have, because it's just a script.
Any ideas on where I should look for some info?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要从 facebook 获取您的 Facebook_App_Id 和 Facebook_App_Secret,您将在注册应用程序时获得。
然后添加所需的网址。
您的消费者密钥和消费者秘密分别是 Facebook 应用程序 ID 和 Facebook 应用程序秘密。
您基本上可以按照 Oauth2.0 指南获取 access_token,并将 access_token 和粉丝页面 id 存储在数据库中的某个位置。 https://github.com/simplegeo/python-oauth2 是一个关于如何获取 oauth 令牌。然后,当您尝试发布时,请使用类似这样的内容来使用访问令牌。
这应该适用于发布到用户的墙上。但我确信在 Facebook 粉丝页面上发帖应该是非常相似的。
First You need to get your Facebook_App_Id and Facebook_App_Secret, from facebook which you will get when you register your app.
Then you include the needed urls.
Your consumer key and consumer secret are the Facebook app id and facebook app secret respectively.
You would basically get the access_token following the Oauth2.0 guidelines and store the access_token and fan page idsomewhere in your database. https://github.com/simplegeo/python-oauth2 is a good example on how to get the oauth token. Then when you try to post use the access token by using something like this.
This should work for posting to a user's wall. But i am sure posting to a facebook fan page should be something very similar.