这里是我一直在测试代码:Facebook的Javascript API第 - 有麻烦“连接”
<?php
$accessToken = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials');
$accessToken = explode('=', $accessToken);
$accessToken = $accessToken[1];
?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function()
{
FB.init({
appId: 'APP_ID',
status: true,
cookie: true,
xfbml: true
});
FB.api('/me?access_token=<?php echo $accessToken; ?>', function(user)
{
if (user != null)
{
console.log(user);
}
});
};
(function()
{
var e = document.createElement('script');
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_GB/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
我收到以下错误返回:
An active access token must be used to query information about the current user.
我注册了我的网站的网址用Facebook获取我的ID /密码,并在注册时指定的目录中运行上述脚本。
我在做什么错?
我其次,Facebook的PHP更好! – Ravikiran 2011-01-28 15:46:49