problem api facebook v3 [duplicate]
Possible Duplicate:
facebook Uncaught OAuthException: An active access token must be used to query information about the current user.
I have a problem with v3 of php api facebook.
This is the error: OAuthException: An active access token must be used to query information about the current user.
This is the code:
$facebook = new Facebook(array(
'appId' => 'xxxxx',
'secret' => 'xxxxx',
));
$user = $facebook->getUser();
$accessToken = $facebook->getAccessToken();
if ($user) {
try {
$events = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo ($e);
}
}
You must redirect to a login url, you can get the url with getLoginUrl
method of facebook object:
if ($user) {
// if accepted
}else{
$loginUrl = $facebook->getLoginUrl(); // redirect to this url.
}
When you accept the application, you'll get an access token and be able to use the api.
精彩评论