PHP Facebook SDK不起作用并返回代码

时间:2017-08-23 17:58:23

标签: php facebook login sdk

我的PHP Facebook SDK无效,总是返回$ user = 0为什么?

这是我第一次处理facebook sdk

我的代码:

require './facebook-php/src/facebook.php';

$facebook = new Facebook(array(
'appId'  => 'xxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxx'
));
// Get User ID
$user = $facebook->getUser();

if ($user) {
try {
  // Proceed knowing you have a logged in user who's authenticated.
     $user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
  }
}

 if($user) {
    $logoutUrl = $facebook->getLogoutUrl();  echo 'there is a user';
} else {
 $loginUrl = $facebook->getLoginUrl();
echo 'there is noo user <a href='.$loginUrl.'>login</a>';
}

下面是网址返回码:
http://localhost/e-commerce/testit.php?code=AQA8DckDMqNarptbCUIfAmn2tIyn1mjVBmHTjOMaQ4GqsFW_6vqemGW35TC07Kxq7kuB4QkKibHJ2-m9GntIx0biWEiR_FUuozsONvgc_tNmtGURpcm78DnIE26vT6hbjz10eZECuh-GLec9tGplhLrDNbLO-aX2Hv2Mu-8CQhAdiFQ6AYW3Nt09a8Rzahbn35Jz0cNyB_G7Ksjorq3iSs6Bpa6Tk0d7Vx0A0f1Mg77PgD6IuN_grjkNHDWmb_ywoqW48IqoxJUhnRmL3qi1G-CT7ft_f77rRr-VP-yQ-LTkdNja0rBzoFnFGccMuQ86u8tk7nfnx5qrSLBpHLEIBqQT&state=84ff9f36e8de53d13c96bcf7cb2da3b3#=

我上传了Facebook设置图片
Facebook settings images

0 个答案:

没有答案