【发布时间】:2014-01-24 13:36:03
【问题描述】:
我已经用 facebook 开发者帐户注册了新应用程序。按照教程,我有这个代码:
<?php
// Remember to copy files from the SDK's src/ directory to a
// directory in your application on the server, such as php-sdk/
require_once('facebook/facebook.php');
$config = array(
'appId' => 'xxxxxxxxxxxx',
'secret' => 'yyyyyyyyyyyyyy',
'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
);
$facebook = new Facebook($config);
$user_id = $facebook->getUser();
?>
<html>
<head></head>
<body>
<?php
if($user_id) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
$user_profile = $facebook->api('/me','GET');
echo "Name: " . $user_profile['name'];
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
$login_url = $facebook->getLoginUrl();
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
我在应用仪表板上设置: 应用程序域:buzzsu.com 网址:buzzsu.com
然后我将上面的代码放在 www.buzzsu.com 中。当我访问该页面时,它会提供我登录。当我点击登录时,它给了我以下错误:
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
我该如何解决?
【问题讨论】:
-
在仪表板上,您添加了
buzzsu.com还是www.buzzsu.com?这很重要。 -
好的!我为 www.buzzsu.com 编辑了应用程序设置。然后在Firefox中我输入了buzzsu.com它没有工作,在我尝试输入www.buzzsu.com并且它工作之后。有什么问题?
标签: php facebook facebook-graph-api