저는이 문제에 대해 지금까지 여러 해 동안 저의 머리를 숙이고 있습니다. JavaScript SDK를로드 한 후에 그래프 API에 GET 호출을 할 수 없습니다. 나는/me/home을 사용하려고 시도하고 있지만 디버깅을 위해서/me도 시도했다. 이상하게도, 사용자의 로그인 상태를 확인하면 주소 표시 줄에서 뉴스 피드를 완벽하게 검색하는 데 사용할 수있는 액세스 토큰이 반환됩니다. 그러나 JavaScript를 사용하여 Graph API에 GET 호출을하면 다음과 같이 표시됩니다.그래프 API가 자바 스크립트 SDK를 사용하여 액세스 토큰을 허용하지 않습니다.
"현재 사용자에 대한 정보를 쿼리하려면 활성 액세스 토큰을 사용해야합니다."
POST는 SDK를 사용하여 사용자 피드를 완벽하게 호출 할 수 있습니다. 마지막으로 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');
};
});
};
와우, 감사합니다! 나는 내 인생에 잘못이 무엇인지 알 수 없었다. – Jimbroze