我正在尝试访问Facebook联系人,代码工作正常,但在尝试注销时,重定向Url无法正常工作,而是重定向到用户的Facebook主页。
<?php
require './src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'App ID',
'secret' => 'App Secret',
));
$user = $facebook->getUser();
if ($user) {
$facebook->destroySession();
header("location: skifi.zapto.org/affiliates/index.php");
}
?>
的index.php
<?php
$file = dirname(__FILE__) . '/src/facebook.php';
if (file_exists($file)) {
require dirname(__FILE__) . '/src/facebook.php';
} else {
echo 'Facebook SDK Not Found';
exit;
}
$facebook = new Facebook(array(
'appId' => 'App ID',
'secret' => 'App Secret',
));
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
$friends = $facebook->api('/me/friends');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
答案 0 :(得分:2)
尝试使用大写字母L和http://
的位置header("Location: http://skifi.zapto.org/affiliates/index.php");
答案 1 :(得分:0)
我就是这样做的,似乎是在我的localhost上工作。
$redirect_page = "http://skifi.zapto.org/affiliates/index.php";
header('Location: ' . $redirect_page);
exit();