Php Facebook getLoginUrl和下一个参数不';我不能正常工作
我的代码:Php Facebook getLoginUrl和下一个参数不';我不能正常工作,php,facebook-graph-api,Php,Facebook Graph Api,我的代码: $url = $fb->getLoginUrl(array('scope'=>'email','next'=>'http://apps.facebook.com/APPID/')); echo "<script> top.location=\"".$url."\"; </script>"; $url=$fb->getLoginUrl(数组('scope'=>'email','next'=>'http://apps.facebook.com/
$url = $fb->getLoginUrl(array('scope'=>'email','next'=>'http://apps.facebook.com/APPID/'));
echo "<script> top.location=\"".$url."\"; </script>";
$url=$fb->getLoginUrl(数组('scope'=>'email','next'=>'http://apps.facebook.com/APPID/'));
echo“top.location=\”.$url.\“;”;
当身份验证成功时,我需要将用户重定向到我的应用程序的应用程序URL,但它总是重定向到我的重定向uri页面
我怎样才能修好它
谢谢。在应用程序设置页面中更改重定向uri。您必须更改此URL,以便在验证后将应用程序重定向到您想要的位置 或者您可以这样做 首先,您不必编辑PHP SDK,下面是验证用户然后重定向到登录页的示例 确保更换: YOUR-APP-ID-此处带有您的facebook应用程序ID YOUR-APP-API-SECRET-此处带有您的facebook应用程序密钥 YOUR-REDIRECT-URL-此处带有登录页URL
<?php
// Requires Facebook PHP SDK 3.0.1: https://github.com/facebook/php-sdk/
require ('facebook.php');
define('FACEBOOK_APP_ID',"YOUR-APP-ID-HERE");
define('FACEBOOK_SECRET',"YOUR-APP-API-SECRET-HERE");
define('REDIRECT_URI',"YOUR-REDIRECT-URL-HERE");
$user = null;
$facebook = new Facebook(array(
'appId' => FACEBOOK_APP_ID,
'secret' => FACEBOOK_SECRET,
'cookie' => true
));
$user = $facebook->getUser(); // Get the UID of the connected user, or 0 if the Facebook user is not connected.
if($user == 0) {
// If the user is not connected to your application, redirect the user to authentication page
/**
* Get a Login URL for use with redirects. By default, full page redirect is
* assumed. If you are using the generated URL with a window.open() call in
* JavaScript, you can pass in display=popup as part of the $params.
*
* The parameters:
* - redirect_uri: the url to go to after a successful login
* - scope: comma separated list of requested extended perms
*/
$login_url = $facebook->getLoginUrl($params = array('redirect_uri' => REDIRECT_URI));
echo ("<script> top.location.href='".$login_url."'</script>");
} else {
// if the user is already connected, then redirect them to landing page or show some content
echo ("<script> window.location.href='".REDIRECT_URI."'</script>");
}
?>
如果在应用程序页面中设置了链接,那么正如Mike所说,将“下一步”值更改为您希望它指向的位置。我将它指向“”,但它总是重定向到我的画布url,我是说它。
$login_url = $facebook->getLoginUrl($params = array('redirect_uri' => REDIRECT_URI,'scope' => 'comma-separated-list-of-requested-extended-perms'));