当用户授权我的应用时,他被重定向到我的网站,而不是我的应用程序在iframe中的facebook。有没有办法留在Facebook? 我的代码:
require './src/facebook.php';
$config = array();
$config['appId'] = 'XXXXX';
$config['secret'] = 'XXXXX';
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
}
// Login or logout url will be needed depending on current user state.
if ($user) {
echo "blah";
} else {
$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'https://xxxxx'
);
$loginUrl = $facebook->getLoginUrl($params);
echo("<script> top.location.href='" . $loginUrl . "'</script>");
}
?>
答案 0 :(得分:0)
尝试将应用的网址(http://apps.facebook.com/your_app_namespace)放在redirect_uri参数中。这应该可以解决您面临的问题。