0

I've read around but I can't find any similar questions so here goes...

I have a facebook application which is configured and working fine, Lets take my website URL to be:

http://adminpanel.its.a.very.long.url.mywebsite.com

This is configured as the 'site URL' in the application config and it works fine.

However, the website is also used on our internal network with a DNS that allows us to use

http://adminpanel/

The problem is that the facebook app wont allow a'redirect_uri' to be

http://adminpanel/

and fails with the following:

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 permitted by the application configuration.

Is it possible to allow both

http://adminpanel.its.a.very.long.url.mywebsite.com

and

http://adminpanel/

Thanks in advance,

Oli

UPDATE: I can't use two apps as I rely the 'Add Page Tab Dialogue' to add my application to various Pages.

What I need is both of these redirects (specified by the 'next' param) to be allowed by facebook.

https://www.facebook.com/dialog/pagetab?app_id=12345678&display=popup&next=http://adminpanel/Success

https://www.facebook.com/dialog/pagetab?app_id=12345678&display=popup&next=http://adminpanel.its.a.very.long.url.mywebsite.com/Success

4

1 回答 1

0

一个常见的问题,很容易解决。在下面查看我的 PHP 代码:

if ( strstr( 'adminpanel', $_SERVER['HTTP_HOST'] ) ) {
    // this is the localhost settings

    $facebook = new Facebook(array(
        'appId'  => 'xxx',
        'secret' => 'xxx',
    ));

    $app_url = 'http://adminpanel/';
    $fb_url = 'http://apps.facebook.com/xxx/';

    //  other settings can go here too

} else {
    // this is the main / live site settings

    $facebook = new Facebook(array(
        'appId'  => 'yyy',
        'secret' => 'yyy',
    ));

    $app_url = 'http://adminpanel.its.a.very.long.url.mywebsite.com';
    $fb_url = 'http://apps.facebook.com/yyy';

    //  other settings can go here too

}

问题解决了!

代码检查host它在哪个运行并为每个加载正确的设置。您需要在 Facebook 上拥有两个不同版本的应用程序。这将允许您分别为每个应用程序配置 URL(如上面的 PHP 代码中所示)。

如果您使用不同的语言,您可以通过检测host并将您的配置设置放在条件语句的相关部分中来轻松地做同样的事情。它甚至允许您配置多个(即超过 2 个)环境。

于 2012-05-23T10:41:59.047 回答