so i did a web app with php facebook sdk and run it on my localhost... everything seems to be fine, the function GetUser got me the user id... then when i upload the web to the a host server GetUser() return always 0... is somebody figure it out?
this is my code, nothing special:
$homeurl = 'http://postmaster.net78.net/MainMenu.php'; //return to home
$fbPermissions = 'user_events,friends_events,read_stream,publish_stream,offline_access';
$facebook = new Facebook(array(
'appId' => '****',
'secret' => '***',
));
$user = $facebook->getUser();
echo $user;
if ($user)
{
.......
}
else
{
$_fb['loginurl'] = $facebook->getLoginUrl(array('redirect_uri'=>$homeurl,'scope' => $fbPermissions));
$_fb['authed'] = false;
echo '<center><br><br><br><br><br><br><br>For start working with <img src="images/logoBlack.gif" height = "8%" width="15%"> <br>you must connect to your facebook account<br>';
echo '<a href="'.$_fb['loginurl'].'"><img src="images/loginwithfacebook.jpg"></a>';
}
thanks for the helpers
I had this same problem. In my case it had to do with cURL and SSL certificate.
I am still trying to figure out why it has no problems on my localhost, I am thinking it could be cURL or SSL settings at my Webhost.
In the meantime A quick fix is to tell cURL to accept any SSL certificate.
Add this to your base_facebook.php file:
$opts[CURLOPT_SSL_VERIFYPEER] = false;
curl_setopt_array($ch, $opts);
Place it right before $result = curl_exec($ch);
From a security point of view it is probably not the best solution but if it works for you it should give you a starting point to find a permanent fix.
See this page for more insight: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.