doufu9836 2013-07-17 17:44
浏览 52

Facebook php sdk getuser()仅在我的localhost上工作

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>';
}

and my developer info: http://img838.imageshack.us/img838/7051/ef7n.png

thanks for the helpers

  • 写回答

1条回答 默认 最新

  • drtoclr046994545 2013-10-13 13:06
    关注

    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/

    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c