Reputation: 1142
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
Upvotes: 0
Views: 151
Reputation: 2519
You're outputting logoutUrl rather than loginUrl
Change:
echo '<a href="$logoutUrl">Login</a>';
to use
echo '<a href="'.$loginURL.'">Login</a>';
Upvotes: 1