1

我尝试了几种方法,例如。这里没有运气。我正在使用他们的facebook php sdk

现在发生的情况是应用程序在通过身份验证后被重定向到我的网站。

<?php 
require_once 'php-sdk/facebook.php';
$app_id = "***";
$app_secret = "***";
$facebook = new Facebook(array(
        'appId'=> $app_id,
        'secret' => $app_secret,
        'cookie' => true
));
$user = $facebook->getUser();
if(!$user)
{
    $auth_url = $facebook->getLoginUrl(array('scope' => 'email'));
    echo("<script> top.location.href='" . $auth_url . "'</script>");
}
?>

我尝试将 auth_url 替换为:

$auth_url = $facebook->getLoginUrl(array('scope' => 'email',
'redirect_uri' => 'http://apps.facebook.com/ridetogether'));

但提示告诉我 redirect_url 不归我所有:

Ride Together 出现错误。请稍后再试。

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.

我还能做些什么来重定向回 facebook 内的画布应用程序?

4

2 回答 2

1

API错误代码:191 API错误描述:指定的URL不属于应用程序错误消息:无效的redirect_uri:应用程序配置不允许给定的URL。

您的命名空间/画布页面在您的应用程序设置中是否正确?您可能需要再次仔细检查。

于 2011-12-06T07:49:51.760 回答
0

您需要在您的域上指定要重定向到的特定页面,如下所示

$params = array(
  'scope' => 'email',
  'redirect_uri' => $authPageURL,
);

$auth_url = $facebook->getLoginUrl($params);

然后该页面需要使用 301 重定向到您的画布 URL。因此,创建一个名为 auth.php 或其中包含此内容的页面

if(isset($_REQUEST['error_reason']))
{
    header('Location: '.$auth_error_page);
}
else 
{       
    header('Location: '.$FB_canvas_page);
}

然后将该页面用作重定向 URI。

于 2011-12-06T11:04:17.503 回答