我在这里看到过类似问题,但要么他们不是在问同样的事情,要么解决方案对我不起作用。我的问题是,这给了我错误日志中的Uncaught OAuthException:
require_once 'fb-php-sdk/facebook.php';
// Facebook App Info
$app_id = MYAPPID;
$app_secret = MYAPPSECRET;
// Load info into config array for Facebook object
$config = array(
'appId' => $app_id,
'secret' => $app_secret,
'fileupload' => false,
'cookie' => true
);
// Initialize Facebook
$fb = new Facebook($config);
// Retrieve user ID
$my_access_token = $fb->getAccessToken();
$uid = $fb->getUser();
// Login if the UID was 0
if (!$uid) {
// Login parameters including redirect URL
$params = array(
'scope' => 'read_stream, friends_likes',
'redirect_uri' => 'MYURL'
);
// Log the user in
$loginUrl = $fb->getLoginUrl($params);
}
echo '<p>w00t!</p>';
echo '<p>token1: ' . $my_access_token;
$user_profile = $fb->api('/me', 'GET', array('access_token' => $my_access_token));
echo '<p>Name: ' . $user_profile['name'] . '</p>';
输出“w00t!”然后是我的令牌,但它从不打印我的用户名,它在我的日志中给出了我的错误。有任何想法吗?我从文档中的示例中获取了用户配置文件代码。