私はこの問題について何年も頭を悩ませてきました。JavaScript SDK をロードした後、グラフ API への GET 呼び出しを行うことができません。/me/home を使用しようとしていますが、デバッグ目的で /me も試しました。奇妙なことに、ユーザーのログイン ステータスを確認すると、アドレス バーでニュース フィードを完全に取得するために使用できるアクセス トークンが返されます。ただし、JavaScript を使用して Graph API への GET 呼び出しを行うとすぐに、次のようになります。
「現在のユーザーに関する情報を照会するには、アクティブなアクセス トークンを使用する必要があります。」
また、SDK を使用して POST でユーザーのフィードを呼び出すこともできます。最後に、read_stream 権限があることを確認しました。
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo($facebook_key); ?>', // App ID
channelUrl : '//'+window.location.hostname+'/channel.php', // Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
// listen for and handle auth.statusChange events
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
console.log(response);
} else {
location.href='welcome.php';
};
});
FB.getLoginStatus(function(response) {
console.log(response);
});
//get Facebook news feed
FB.api('/me/home', 'get', function(response) {
console.log(response);
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
//status update function
function post (form) {
var status = form.status.value;
FB.api('/me/feed', 'post', { message: status }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Status updated');
};
});
};