'を結ぶ' 悩みを持ってここで私がテストしてきたコードです:の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.
私は自分のサイトのURLを登録しました私のID /シークレットを取得するFacebookと私は登録時に指定したディレクトリ内で上記のスクリプトを実行しています。
私は間違っていますか?
私は2番目に、FacebookのPHPが良い方法です! – Ravikiran