Reputation: 2744
I am trying out a bit of Facebook PHP SDK. Here is my code :
<?php
/* Connect to facebook link. */
require_once('./fb/facebook.php');
$facebook = new Facebook(array(
'appId' => '189152054469765',
'secret' => 'ccd2d3e7986fb1ij4c9e41018327db67',
'cookie'=>true
));
echo $facebook->api('/me');
?>
On running the file, I am getting the error: Uncaught OAuthException: An active access token must be used to query information about the current user. I've seen the above code working for all in all tutorials. I am logged into facebook and given permissions for email and publish_stream to my app.
Upvotes: 3
Views: 457
Reputation: 6155
You need to perform oauth authentication (basically redirects with token exchange).
So you check for
$user = $facebook->getUser();
And if not, you click on $facebook->getLoginUrl();
Upvotes: 1