我的应用程序位于粉丝页面内,当我请求权限时,它会显示对话框。 问题是在用户接受后,他们被重定向到真正的应用页面(这里的应用程序是url)
为了更好地理解我有用PHP PHP SDK生成的url
我们可以看到将重定向到facebook之外,我想重定向回来 在这种情况下:https://www.facebook.com/mypage/app_341572315885516
有什么方法可以解决这种情况吗?我尝试了很多无用的东西......
我的代码:
<?php $userid = Yii::app()->facebook->getUser(); ?>
<?php $results = NULL;//$results = Yii::app()->facebook->api('/me'); ?>
<?php
$signed_request = Yii::app()->facebook->getSignedRequest();
if(!isset($signed_request['page']) || !isset($signed_request['page']['liked']))
{
$this->renderPartial('_nofan', array('model'=>$model));
}
else
{
if(!$signed_request['page']['liked'])
{
$this->renderPartial('_nofan', array('model'=>$model));
}
else
{
try
{
$results = Yii::app()->facebook->api('/me');
}
catch (FacebookApiException $e) {
}
if(!$userid || !$results)
{
$loginUrl = Yii::app()->facebook->getLoginUrl(array('scope'=>'user_about_me,user_birthday'));
/*echo "<script type='text/javascript'>top.location.href = '{$loginUrl}';</script>";*/
Yii::app()->clientScript->registerScript('login-perm', 'top.location.href = "'.$loginUrl.'";', CClientScript::POS_HEAD);
//$this->redirect($loginUrl);
/*Yii::app()->facebook->addJsCallback("FB.login(function(response) {
if (response.authResponse) {
// user is logged in and granted some permissions.
} else {
// User cancelled login or did not fully authorize.
}
}, {scope:'user_about_me,user_birthday'});");*/
}
// FAN
//echo 'Olá';
}
}
?>
由于
答案 0 :(得分:0)
您可以尝试redirect_uri
参数,
例如:
$redirecturl = https://www.facebook.com/mypageonfacebook/app_APPID;
$params = array('scope' => 'email, publish_actions', 'redirect_uri' => $redirecturl);
$loginUrl = $facebook->getLoginUrl($params);
echo("<script> top.location.href='".$loginUrl."'</script>");
希望这会对你有所帮助..谢谢..