I’m using the Facebook PHP SDK to register new users with data pulled from the Facebook API.
When I visit the page with the code below, the echo $uid returns nothing. Not 0. Not null. Just nothing.
The simplified code looks like this:
$config = array();
$config['appId'] = $appid;
$config['secret'] = $appsecret;
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$uid = $facebook->getUser();
$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'http://www.website.com',
'display' => 'page', //could be popup
'cookie' => true,
);
$loginUrl = $facebook->getLoginUrl($params);
echo 'uid = '.$uid;
if($uid) {
//SHOW SOMETHIN'
echo 'AUTHORIZED!';
//CREATE NEW USER...
//SIGN IN NEWLY CREATED USER...
} else {
//PROMPT TO AUTHORIZE
echo '<a href="' . $loginUrl . '">SIGN IN WITH FACEBOOK.</a>';
};
What am I missing?
get_permalink($post->ID)should be the culprit.Is it the same you specified as
Site URLin app settings ?(My little wp knowledge says, this url is going to be dynamic)
For security reasons, facebook redirect to
Site URLonly and not just any url.