我有一个在hostgator.com中共享ssl的主机,我在public_html(根)目录中上传了codeIgniter站点。我想开发一个网站以及facebook的应用程序。网站运行成功与‘登录facebook’当运行facebook应用程序时,它给出一个url重定向错误。
这是http url。
url(Website): http://example.org/
而安全url是
https://in9.hostgator.in/~username/
在facebook应用程序配置中,
canvas url : http://example.org/
Secure Canvas URL : https://in9.hostgator.in/~username/ (Work in url)
当我运行facebook应用程序时,facebook给出一个错误:
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.
在应用程序中,没有用于重定向或删除根目录中index.php的.htaccess文件。
我已经运行了这个基本控制器代码:
public function __construct()
{
parent::__construct();
$this->load->library("session");
$this->load->helper('cookie');
parse_str( $_SERVER['QUERY_STRING'], $_REQUEST );
$CI = & get_instance();
$CI->config->load("facebook",TRUE);
$config = $CI->config->item('facebook');
$this->load->library('Facebook', $config);
}
/**
* Index function
* @access public
*
public function index()
{
$userId = $this->facebook->getUser();
// If user is not yet authenticated, the id will be zero
if($userId == 0){
// Generate a login url
$params = array(
'scope' => 'email,user_about_me, user_birthday, user_location');
$url = $this->facebook->getLoginUrl($params);
echo "<script type='text/javascript'>" . "top.location.href = '" . $url. "';</script>";
}
}
当我打印'$url‘时,查询字符串中的redirect_url是'http://in9.hostgator.in/~username/',而不是重定向到https路径。
我很困惑,什么是代码中的错误?或者服务器中的一些错误配置,或者其他什么?
发布于 2013-04-07 20:44:30
Facebook应用程序也有一个“应用程序域名”设置,如果画布网址不在列出的域名下,facebook sdk将无法工作。尝试在其中同时添加example.org
和hostgator.in
。
或者,您可以使用facebook canvas url作为重定向uri,因此,如果您的facebook应用程序的名称空间是my-facebook-app
,那么您可以生成如下所示的登录url:
$this->facebook->getLoginUrl(array(
'scope' => 'email,user_about_me, user_birthday, user_location',
// change the last segment to you app's namespace
'redirect_uri' => 'https://apps.facebook.com/my-facebook-app/'
));
对于canvas应用程序,这可能更可行,因为如果重定向uri直接指向您的安全canvas url,则用户在进行身份验证时将“松散”facebook。
https://stackoverflow.com/questions/15866052
复制相似问题