Facebook Group Feed PHP SDK

我与影子孤独终老i 提交于 2019-12-24 06:59:10

问题


Okay, I'm getting completely confused here.

The facebook API has baffled me and I've not got a single clue what I'm doing, I keep seeing terminology getting slung around like "user your auth token" and such, However I'm clueless on how I go about to get all this setup and working, so without just getting a link pasted as an answer could we get some explanations, almost tutorial-esque responses please.

The situation is as below:

Dev webserver with a cron job setup to download each days posts from a private group to a database (can do this once I've got the feed).

What we've got.

  • 1 Admin account for the private Group (not owner)
  • 1 App setup on that admin accounts facebook- only to the point where required fields have been entered, so we have a App ID and App Secret.

However, whenever I try gain access to the feed via graph.facebook.com I either get only the ID of the group, or oAuth failed.

The data I want is https://graph.facebook.com/473828522631951?fields=feed&access_token=CAAAAAITEghMBAPeTF7ENB5H6yUGS6Jzj8azTzJAe9CwOrjAsaZCTziFklDvnkO4AKRAbZCXlBIZCK58ZCR7JlLaNVYx2rcgvNJIRzqjr6RLZBZBaG0W6Dq88DfjvIxFy3Ctg4JZB7rRNOc58BjNmPaGFYzplW7DOMzSXtJKXL2j2QZDZD here (however I copied this link from facebook dev page, so I guess the access token will shortly expire)

This is basically the result I want, however I cant figure out how to setup the app correctly/gain permissions to access the apps feed, or anything.

Could somebody please shed some light on how to exactly get the Feed of a private facebook group, via either the PHP SDK, CURL or file_get_contents or however.

Many desperate thanks


回答1:


Since your group is private only users belonging to that group can see the feed. That means you will need a user access token. The url you want to access is https://graph.facebook.com/473828522631951/feed/?access_token=yourtoken

You can extend tokens as described at https://developers.facebook.com/docs/facebook-login/access-tokens/

Find the section titled "Expiration and Extending Tokens". These tokens last for 60 days. I resolved a similar problem in django/python by constructing an admin page in which I login periodically through facebook (every 60 days). Upon login success, it will write the user access token into a configuration file (I use config.yaml). My app reads the token in the config file and uses it to access the group's data through the Facebook Graph API. Before the token expires, you can have your app email the site admins telling them to login again to rewrite the token in the configuration file.https://developers.facebook.com/docs/reference/php/ https://developers.facebook.com/docs/reference/api/group/ https://developers.facebook.com/docs/reference/dialogs/oauth/



来源:https://stackoverflow.com/questions/16945719/facebook-group-feed-php-sdk

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