为什么这个代码抛出一个Facebook API错误191? [英] Why does this code throw a Facebook API Error 191?
问题描述
<?php
require_once'library / facebook.php';
$ app_id =xyz;
$ app_secret =xyz
$ facebook = new Facebook(array(
'appId'=> $ app_id,
'secret'=> $ app_secret,
'cookie'=> true
));
if(is_null($ facebook-> getUser()))
{
header(Location:{$ facebook-> getLoginUrl(array('req_perms'=>'user_status ,publish_stream,user_photos'))});
退出;
}
?>
注册应用程序时使用的网址是 http://www.sitename.com/facebook/
所以运行这个文件应该指引我到一个授权页面...而不是我得到以下错误:
API错误代码:191
API错误说明:指定的URL不属于应用程序
错误消息:redirect_uri不属于应用程序。
任何一个人都可以解释如何解决这个问题,为什么会这样?
错误原因191:
在Facebook应用程序设置中,站点URL与REQUEST_URI不同(重定向网址)
例如
如果您指定网站网址为 http://www.sitename.com/facebook/
则您不允许重定向到 http://www.namesite.com/facebook/
I have the following config.php file sitting at www.sitename.com/facebook/
<?php
require_once 'library/facebook.php';
$app_id = "xyz";
$app_secret ="xyz"
$facebook = new Facebook(array (
'appId' => $app_id,
'secret'=> $app_secret,
'cookie'=> true
));
if(is_null ($facebook->getUser()))
{
header("Location:{$facebook->getLoginUrl(array('req_perms'=>'user_status, publish_stream, user_photos'))}");
exit;
}
?>
The site URL used in registering the app is http://www.sitename.com/facebook/
so running this file should direct me to an authorization page...instead i get the following 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.
Can any one explain how to get around this and why this happens?
Reason for error 191:
In Facebook Application Setting, Site URL is not same as REQUEST_URI (Redirecting URL)
e.g.,
if you specified site URL to http://www.sitename.com/facebook/
then you are not allow to redirect to http://www.namesite.com/facebook/
这篇关于为什么这个代码抛出一个Facebook API错误191?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!