duandingcu7010 2013-06-25 07:39
浏览 173
已采纳

$ facebook-> getUser()突然停止工作

I've got a login with facebook on my website. This has worked well for some time but yesterday suddenly stopped working. I've tracked the problem to the getUser() method which seems to always returns 0 now.

my code looks like:

<?php
require_once('facebook.php');

$facebook = new Facebook(array(
  'appId'  => 'xxxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
));

$user = $facebook->getUser();
if ($user) {
  try {
    $profile = $facebook->api('/me');
    $logoutUrl = $facebook->getLogoutUrl(
        array(
            'next'=>$baseUrl.'/fblogin/fblogin.php?logout'
        )
    );
    $userIsLoggedIn=true;

  } catch (FacebookApiException $e) {
    echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
    $user = null;
    $loginUrl = $facebook->getLoginUrl(
        array(
            'scope'=>'email,publish_stream',
            'redirect_uri'=>$returnAfterLoginUrl
        )
    );
  }
}else{
    $loginUrl = $facebook->getLoginUrl(
        array(
            'scope'=>'email,publish_stream',
            'redirect_uri'=>$returnAfterLoginUrl
        )
    );
}
?>

What I've tried (and could find back in my history)

  1. Update the SDK to the latest version
  2. Solution of Facebook PHP SDK - getUser() suddenly returns 0 (adding 2 $CURL_OPTS)
  3. Solution of suddenly, getUser became to return 0.(PHP 3.1.1 SDK) (adding base_domain to $DROP_QUERY_PARAMS)
  4. Solution of Facebook login is suddenly not working anymore? (increasing curlopt_connecttimeout)
  5. Creating a new app, without luck

I'm using PHP Version 5.3.3

I've been trying to get it working since yesterday afternoon, without any luck :(

Does anyone know what might be the problem and more importantly, what might be the solution?

Thank you

  • 写回答

5条回答 默认 最新

  • dongyirong3564 2013-07-05 06:03
    关注

    Solved it by moving the script to another subdirectory on the server... /login/ became /facebook/login/

    I haven't got the slightest clue why that makes a difference...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线