简体   繁体   English

Facebook canvas应用程序身份验证重定向到我的域

[英]Facebook canvas app authentication redirects to my domain

I tried several approaches, for eg. 我尝试了几种方法,例如。 here with no luck. 这里没有运气。 I'm using their facebook php sdk . 我正在使用他们的facebook php sdk

What happens now is that the app gets redirected to my site after getting authenticated. 现在发生的是,该应用程序在获得身份验证后被重定向到我的网站。

<?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>");
}
?>

I tried replacing auth_url with: 我尝试将auth_url替换为:

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

but the prompt told me that the redirect_url is not owned by me: 但是提示告诉我redirect_url不属于我:

An error occurred with Ride Together. 一起骑行时发生错误。 Please try again later. 请稍后再试。

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.

What else can I do to just redirect back to the canvas app inside facebook? 我还能做些什么,以仅重定向回到facebook内的canvas应用程序?

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. API错误代码:191 API错误描述:应用程序不拥有指定的URL错误消息:无效的redirect_uri:应用程序配置不允许给定的URL。

Is your namespace/canvas page correct at your application setting? 您的名称空间/画布页面在您的应用程序设置正确吗? You might have to double check that again. 您可能需要再次仔细检查。

You need to specify a specific page on your domain to redirect to, like this 您需要在您的域上指定要重定向到的特定页面,例如

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

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

Then that page needs to redirect to your canvas URL using a 301. So create a page called auth.php or something that has this in it 然后,该页面需要使用301重定向到您的画布URL。因此,请创建一个名为auth.php的页面或包含该页面的内容

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

Then use that page as the redirect URI. 然后使用该页面作为重定向URI。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM