How to build a Facebook app with PHP that shows albums?

偶尔善良 提交于 2019-12-24 10:58:22

问题


I want to build a Facebook web application that uses the graph API to show only the albums of a specific user. That user is always the same, and I know his credentials.

My code so far:

$this->facebook->api("username/albums?access_token=" . $this->access_token);

But I get the following exception:

[error] => Array
(
    [message] => A user access token is required to request this resource.
    [type] => OAuthException
    [code] => 102
)

I need to generate an acces_token that lives forever and is able to retrieve this information, because right now I can only access public data. Where do I have to start?


回答1:


When you have a registered app you can generate an app access token which is always valid.

Use this URL to get your access token:

https://graph.facebook.com/oauth/access_token?
    client_id=YOUR_APP_ID
   &client_secret=YOUR_APP_SECRET
   &grant_type=client_credentials

You can find the App id and App secret on your apps page.
Please note that the albums and/or photos you see depend on the privacy settings of the albums/photo/



来源:https://stackoverflow.com/questions/12110934/how-to-build-a-facebook-app-with-php-that-shows-albums

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