如何使用 Python/Django 在 Facebook 中获取(和使用)扩展权限
我正在尝试编写一个简单的应用程序,让用户授予我的代码写入其页面的 Facebook 流的权限。据我了解,它应该很简单:
- 让用户单击一个按钮,启动一个弹出窗口,其中包含我的 Facebook 应用程序中的页面。
- 在该页面中,他们单击向我的应用授予 stream_publish 的内容并分配该权限到他们的页面。
- 窗口关闭,我现在拥有了在 cron 中运行脚本以将内容推送到该页面的流所需的所有信息。
我已经阅读维基百科好几天了。 pyfacebook 上的注释至少已经过时一年了,人们已经将我指向 socialauth< /a> Django 应用程序似乎同样过时,并且专注于针对用户而不是他们的页面。我什至无法做到上面的#1,更不用说#2 和3 了。
如果有人可以向我展示如何使用 Django/Python 来请求/接收写入 Facebook 流的权限,那将是一个很好的开始。
任何帮助将不胜感激。
I'm trying to write a simple app that lets a user grant my code permission to write to her page's Facebook stream. As I understand it, it should be as easy as:
- Have the user click on a button that launches a popup containing the a page in my Facebook app.
- In that page, they click on something that grants stream_publish to my app and assigns that permission to their page.
- Window closes, I now have all the info I need to run a script in cron to push stuff to that page's stream.
I've been reading the wiki for days. Notes on pyfacebook are at least a year out of date, and people have pointed me to the socialauth app for Django which appears to be equally out of date and focused on targeting users as opposed to their pages. I can't even do #1 up there, let along #2 and 3.
If someone could show me how to use Django/Python to request/receive permission to write to a Facebook stream, that would be a great start.
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您看过 minifb 吗?他们的示例页面基本上显示了您请求授权和接收授权所需了解的所有内容会话密钥。 (此外, pyfacebook 的 github 页面 显示该库仍然存在)
因此,对于您的场景,您需要:
为此,基本上,在您的模板上添加此表单:
顺便说一下,向 Facebook 开发人员致敬。非常好的官方文档。
编辑:我还不能发表评论,所以:如果您在获取 uid 时遇到问题,请检查这个问题和参考文献。
Have you looked at minifb? Their examples page shows basically everything you need to know to request authorization and receive a session key. (Also, the github page for pyfacebook shows that the library is still alive)
So, for your scenario you'd need:
For this, basically, add this form on your template:
Kudos to the Facebook developers, by the way. Very nice official documentation.
EDIT: I'm not allowed to comment yet so: Should you face problems getting the uid, check this question and the references.
经过大量修改后,我似乎已经解决了 Facebookland 中的所有问题:
enable_profile_selector=1
,这将确保生成一个页面列表,用户可以从中选择哪些页面(如果有)将授予这些权限。不管怎样,如果有人感兴趣的话,我在我的博客上详细介绍了这一切。感谢您的帮助!
After a lot of tinkering, I appear to have solved all of my problems in Facebookland:
enable_profile_selector=1
which will make sure that a list of pages is generated from which the user can select which pages (if any) will grant these permissions.Anyway, I detailed it all on my blog if anyone is interested. Thanks for your help!