I want to get permission to post on a user’s Facebook wall and view their likes. I’m using the standard PHP SDK. When I login, it shows the correct Facebook screen asking for those permissions, but when I confirm and it redirects back to my site, it only has ‘state’ and ‘code’ as GET parameters and it still asks me to login. Here’s the code I’m using:
require 'fbsdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'xxxx',
'secret' => 'xxxx',
));
// Get User ID
$user = $facebook->getUser();
if ($user) {
echo 'You have successfully registered your Facebook account.';
} else {
$params = array('scope'=>'publish_stream,user_likes');
$loginUrl = $facebook->getLoginUrl($params);
echo '<a href="' . $loginUrl . '">Login with Facebook</a>';
}
I put this into a page on WordPress/Buddypress with a php module, it seems to have some conflict, as it works fine on it’s own page.