[英]Facebook URL by using php sdk is not loading
I use the following code to connect to the facebook via my site, but the facebook page is not loading. 我使用以下代码通过我的网站连接到Facebook,但是Facebook页面未加载。 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 当我单击登录名时如果在此处单击该登录名,则不会加载Facebook
what should I do in this case 在这种情况下我该怎么办
You're outputting logoutUrl rather than loginUrl 您正在输出logoutUrl而不是loginUrl
Change: 更改:
echo '<a href="$logoutUrl">Login</a>';
to use 使用
echo '<a href="'.$loginURL.'">Login</a>';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.