我有下面的代码,这是工作的一部分的Facebook的OAuth URL问题
<?php
require_once 'facebook.php';
$app_id = 'MY_APP_ID';
$app_secret = 'MY_APP_SECRET';
$app_url = 'http://mysite.com/index.php/';
$scope = 'user_about_me';
// Init the Facebook SDK
$facebook = new Facebook(array(
'appId' => $app_id,
'secret' => $app_secret,
'cookie' => true
));
// Get the current user
$user = $facebook->getUser();
// If the user has not installed the app, redirect them to the Auth Dialog
if (!$user) {
$loginUrl = $facebook->getLoginUrl(array(
'scope' => $scope,
'redirect_uri' => $app_url,
));
print('<script> top.location.href=\'' . $loginUrl . '\'</script>');
}
$user_profile = $facebook->api('/me');
echo "id: " . $user_profile['id'];
?>
我得到这个页面上打印出正确的ID,但在其他几页,我去到如果(!$用户) 。
但有在OAuth网址的错误:
API错误代码:191 API错误描述:指定的URL不会被应用 错误消息资:无效REDIRECT_URI:给定的URL不会被允许应用程序配置。
我发现这里的计算器类似的问题,但似乎无法修复它:/
在我的设置,我有相同的URL和$ APP_URL
网站与Facebook - >网站的网址 - >https://www.facebook.com/pages/myappname/373671679372127/
编辑:编辑我APP_URL,所以现在是一样的下应用程序设置我的画布网址:http://mysite.com/index.php/
现在我没有得到一个错误。我只是得到了一个空白窗口:(
编辑:Importent测试时清除Cookie一次,同时否则一些非常随机错误的地方
在Facebook开发人员中编辑应用程序时,您确定您的域名已填入“应用程序域名”吗?如果你想在你的web应用程序中完全访问你的应用程序,那么填写你的主域名,而不要限制你的子域名。 –
我的应用程序域是:mywebsite.com(没有http和任何/)。 Facebook不停地抱怨我在那里写的东西 – Pavenhimself