Facebook API 错误 191 [英] Facebook API error 191

查看:29
本文介绍了Facebook API 错误 191的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的项目与 Facebook 集成.我刚开始采取一些小步骤,只是尝试登录、获取 Facebook 会话并获取一些用户数据.我正在本地开发它,所以我的 Facebook 应用程序设置是:

网站网址:http://127.0.0.1:8888/mySite/

画布 URL 与上面相同.我没有指定站点域.

但是,当我单击登录按钮时,出现错误:

API 错误代码:191API 错误描述:指定的 URL 不属于应用程序错误消息:redirect_uri 不属于应用程序.

目前我还没有编写任何服务器端代码来处理重定向等.我所做的只是根据,我震惊它清楚地说明如果您在本地开发,您可以使用 http://localhost:8080/ 作为 站点 URL:

<块引用>

配置站点 URL,并指向它到您的 Web 服务器.如果你是在本地开发,你可以使用http://localhost:8080/

虽然我确定你不能这样做,但根据我自己的经验(虽然是很老的测试),你似乎可以强> 在本地测试您的 Facebook 应用程序!

所以我拿起了我的一个旧应用程序并编辑了它的名称、站点 URL 和画布 URL:网站地址:http://localhost:80/fblocal/

我下载了最新的 Facebook PHP-SDK 并将其放入我的 xampp/htdocs/fblocal/ 文件夹.

但是我遇到了和你一样的错误!我注意到 XAMPP 正在自动重定向到 http://localhost/fblocal/ 所以我将设置更改为简单的 http://localhost/fblocal/ 并且错误消失了但是我不得不删除应用程序(从 隐私设置)并重新安装我的应用程序,结果如下:

之后,请求 publish_stream 权限,我就可以发布到我的个人资料(使用 PHP-SDK):

$user = $facebook->getUser();如果($用户){尝试 {$post = $facebook->api('/me/feed', 'post', array('message'=>'Hello World, from localhost!'));} catch (FacebookApiException $e) {错误日志($e);$用户=空;}}

结果:

I'm trying to integrate my project with Facebook. I'm taking baby steps at first and just trying to login, get a Facebook session, and get some user data. I'm developing it locally so my Facebook application settings are:

site URL: http://127.0.0.1:8888/mySite/

The canvas URL is the same as above. I haven't specified a site domain.

However, when I click on the login button, I get an error:

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.

At the moment I haven't written any server-side code to deal with redirects, etc. All I've done is add the JavaScript SDK based on the tutorial in Facebook for Websites.

What have I done wrong? It's obviously something to do with my Facebook application settings, but I can't see what!

解决方案

UPDATE:
To answer the API Error Code: 191
The redirect_uri should be equal (or relative) to the Site URL.

Tip: Use base URLs instead of full URLs pointing to specific pages.

NOT RECOMMENDED: For example, if you use www.mydomain.com/fb/test.html as your Site URL and having www.mydomain.com/fb/secondPage.html as redirect_uri this will give you the 191 error.

RECOMMENDED: So instead have your Site URL set to a base URL like: www.mydomain.com/ OR www.mydomain.com/fb/.


I went through the Facebook Python sample application today, and I was shocked it was stating clearly that you can use http://localhost:8080/ as Site URL if you are developing locally:

Configure the Site URL, and point it to your Web Server. If you're developing locally, you can use http://localhost:8080/

While I was sure you can't do that, based on my own experience (very old test though) it seems that you actually CAN test your Facebook application locally!

So I picked up an old application of mine and edited its name, Site URL and Canvas URL: Site URL: http://localhost:80/fblocal/

I downloaded the latest Facebook PHP-SDK and threw it in my xampp/htdocs/fblocal/ folder.

But I got the same error as yours! I noticed that XAMPP is doing an automatic redirection to http://localhost/fblocal/ so I changed the setting to simply http://localhost/fblocal/ and the error was gone BUT I had to remove the application (from privacy settings) and re-install my application and here are the results:

After that, asked for the publish_stream permission, and I was able to publish to my profile (using the PHP-SDK):

$user = $facebook->getUser();
if ($user) {
    try {
        $post = $facebook->api('/me/feed', 'post', array('message'=>'Hello World, from localhost!'));
    } catch (FacebookApiException $e) {
        error_log($e);
        $user = null;
    }
}

Results:

这篇关于Facebook API 错误 191的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆