我需要一些幫助從Facebook獲取一些JSON,基本上我需要做的就是獲取狀態文本並將其發佈到網站。獲取Facebook的JSON?
我正在使用下面的方法,但此方法的access_tokens每小時過期。
$.getJSON('https://graph.facebook.com/SOME_ID?fields=statuses.limit(10).fields(message)&access_token=SOME_ACCESS_TOKEN', function(data) {});
請注意,我從Facebook圖形API資源管理器得到了上面的網址。
任何其他方式來實現我想要做的?
更新:
我用FB.api,但我不知道我是否已經正確地完成它,因爲它是給我這個錯誤 「訪問令牌才能申請此資源「。
window.fbAsyncInit = function() {
FB.init({
appId : 'My_app_id', // App ID
channelUrl : '//myHost.com/facebook/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
});
FB.api('USER_ID?fields=statuses.fields(message)', function(response) {
console.log(response);
});
// Additional initialization code here
};
// 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));
請注意,我用正確的值替換了(my_app_id,myHost.com和USER_ID)。
在此先感謝。
如果答案是有幫助的 - 其標記爲 「接受」。這將結束這個問題。 – Artemix