问题
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