How to get (and use) extended permissions in Facebook with Python/Django

半腔热情 提交于 2019-12-02 23:48:06
Caio Romão

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:

  1. Request the "stream_publish" permission. There are some ways to do it, but I'd actually go for the easiest: submitting a form (note I've never done an app for facebook, I'm probably wrong assuming this approach is the easiest :-)
  2. Use your application normally: call the API methods using the user_id of the user that authorized your application (you'll have to store it) and, since you were authorized, it shouldn't fail.

For this, basically, add this form on your template:

<form promptpermission="publish_stream">
<input type="submit" value="Allow Publish Stream">
</form>

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.

Daniel Quinn

After a lot of tinkering, I appear to have solved all of my problems in Facebookland:

  1. Turns out that having a user click on a button to grant permissions is as easy as Caio Romão said it was. For my part though, I found that directing them to the Facebook Desktop App link was way easier and more dependable.
  2. Using this link method, Facebook allows you to specify 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.
  3. For this one though, Facebook is totally broken. While in #2 they allow the user to select a page to grant permissions, they don't pass this information onto the application either by way of a POST or in the headers. It's just not there. Instead, you have to do an ugly trick with FQL and some additional questions to the user to make it work.

Anyway, I detailed it all on my blog if anyone is interested. Thanks for your help!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!