我使用以下代码通过我的网站连接到Facebook,但Facebook页面未加载。 厨师就是那样
<?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>
当我点击登录时 If you click on that login here it does not load the facebook
在这种情况下我该怎么做
答案 0 :(得分:1)
您输出的是logoutUrl而不是loginUrl
变化:
echo '<a href="$logoutUrl">Login</a>';
使用
echo '<a href="'.$loginURL.'">Login</a>';