這裏是我一直在測試代碼: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