UPDATE:
To answer the API Error Code: 191
The redirect_uri
should be equal (or relative) to the Site URL.
Tip:使用基本 URL 而不是指向特定页面的完整 URL。
不建议:例如,如果您使用www.mydomain.com/fb/test.html
作为您的网站 URL 并具有www.mydomain.com/fb/secondPage.html
as redirect_uri
这会给你 191 错误。
受到推崇的:因此,请将您的站点 URL 设置为基本 URL,例如:www.mydomain.com/
OR www.mydomain.com/fb/
.
我通过脸书Python 示例应用程序 http://developers.facebook.com/docs/samples/canvas今天,我是shocked它清楚地表明你可以使用http://localhost:8080/
as Site URL如果您在本地开发:
配置站点 URL,并将其指向
到您的网络服务器。如果你是
本地开发,您可以使用http://localhost-8080.com/ http://localhost:8080/
While I was当然你不能这样做,根据我自己的经验(虽然很旧的测试)看来你实际上CAN在本地测试您的 Facebook 应用程序!
所以我拿起我的一个旧应用程序并编辑了它的名称、站点 URL 和画布 URL:
网站网址:http://localhost:80/fblocal/
我下载了最新的Facebook PHP-SDK http://github.com/facebook/php-sdk并把它扔进我的xampp/htdocs/fblocal/
folder.
But I got the same error as yours! I noticed that XAMPP http://en.wikipedia.org/wiki/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 http://www.facebook.com/settings/?tab=privacy) and re-install my application and here are the results:
![alt text](https://i.stack.imgur.com/Faa1J.png)
之后,询问了publish_stream
许可,并且我能够发布到我的个人资料(使用 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:
![alt text](https://i.stack.imgur.com/RKhMs.png)