doutao1939 2014-01-01 00:19
浏览 41
已采纳

使用php sdk的Facebook URL未加载

I use the following code to connect to the facebook via my site, but the facebook page is not loading. The cook is like that

    <?php
require 'src/facebook.php';
$facebook = new Facebook(array(
  'appId'  => '198516340340394',
  'secret' => 'f11117b96e0996ecbf7d7f4919c0cf70',
  'cookie' => true
));
$user = $facebook->getUser();
$user_profile = null;
if ($user) {

try {
    $user_profile = $facebook->api('/me');
    $facebook->api('/me/feed/', 'post', array(
    'message' => 'I want to display this message on my wall'
));
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }

}

if ($user_profile) {
  $logoutUrl = $facebook->getLogoutUrl();
  echo '<a href="$logoutUrl">Logout</a>';
} else {
  $loginUrl = $facebook->getLoginUrl(array(
  'scope' => 'publish_stream, read_friendlists',
  ));
  echo '<a href="$logoutUrl">Login</a>';
}
?>

<html>
<head>
<title>PHP SDK</title>
</head>
<body>


</body>
</html>

and when I click on the login If you click on that login here it does not load the facebook

what should I do in this case

  • 写回答

1条回答 默认 最新

  • doulangbi6869 2014-01-01 00:28
    关注

    You're outputting logoutUrl rather than loginUrl

    Change:

    echo '<a href="$logoutUrl">Login</a>';
    

    to use

    echo '<a href="'.$loginURL.'">Login</a>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法