简体   繁体   English

$ facebook-> API( '/我'); 有时不加载

[英]$facebook->api('/me'); sometimes doesn't load

I have problem with. 我有问题。 $user_profile = $facebook->api('/me'); $ user_profile = $ facebook-> api('/ me'); Sometimes it's working and sometimes it's not. 有时它工作,有时它不工作。

in 8 of 10 cases it's working and suddenly I have an empty string in $user_profile. 在10个案例中的8个案例中,它正在工作,突然我在$ user_profile中有一个空字符串。 Where is the magic? 魔术在哪里?

(I have the newest php SDK implemented) (我已经实现了最新的php SDK)

// FB lib
require_once './libs/facebook.php';
error_reporting(0);

// connect
$facebook = new Facebook(array(  
    'appId'  => 'xxx',  
    'secret' => 'xxx',  
    'cookie' => true
)); 

$user = $facebook->getUser();
$fb_id = $facebook->getUser();

if ($user) {
    try {
        $_SESSION['user'] = $user_profile = $facebook->api('/me');
        $_SESSION['fb_id'] = $fb_id;
} catch (FacebookApiException $e) {
    error_log($e);
    $user = NULL;
  }
}

if ($user == NULL) {
   $loginUrl = $facebook->getLoginUrl(
       array(
        'display' => 'popup',
        'scope' => 'publish_stream, user_likes',
        'redirect_url' => 'https://xxxx.cz/xxxx/canvas/index.php'
    )
);    
} else {  
     $_SESSION['fb_id'] = $fb_id;
     header("Location: https://xxxx.cz/xxxx/xxxx.php");
}

The magic comes from Facebook , their platform seems to be unstable , you are dependent from their servers which might not work always. 魔术来自Facebook,他们的平台似乎不稳定,你依赖他们的服务器,这可能永远不会起作用。

I know that you expect a solution , but really there is only answer to explain why it does not work. 我知道你期待一个解决方案,但实际上只有答案可以解释为什么它不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM