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条)

报告相同问题?

悬赏问题

  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 angular开发过程中,想要读取模型文件,即图1的335行,会报404错误(如图2)。但我的springboot里配置了静态资源文件,如图3。且在该地址下我有模型文件如图4,请问该问题该如何解决呢?
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了
  • ¥100 H5网页如何调用微信扫一扫功能?
  • ¥15 讲解电路图,付费求解
  • ¥15 有偿请教计算电磁学的问题涉及到空间中时域UTD和FDTD算法结合的
  • ¥15 vite打包后,页面出现h.createElement is not a function,但本地运行正常
  • ¥15 Java,消息推送配置