0
我試圖使用JavaScript在客戶端的網頁上顯示來自公共Facebook頁面的留言和評論。我知道我需要一個access_token,但問題是每隔一段時間就會過期。看來我需要動態獲取access_token來避免這個問題。有沒有人知道一種方法來做這個客戶端?Access_token在JavaScript中調用圖形API調用
我試圖使用JavaScript在客戶端的網頁上顯示來自公共Facebook頁面的留言和評論。我知道我需要一個access_token,但問題是每隔一段時間就會過期。看來我需要動態獲取access_token來避免這個問題。有沒有人知道一種方法來做這個客戶端?Access_token在JavaScript中調用圖形API調用
簡短的回答:
如果頁面確實是公開的,你並不需要一個訪問令牌的。例如,
http://graph.facebook.com/19292868552
{
"id": "19292868552",
"name": "Facebook Platform",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-ash2/276791_19292868552_1958181823_s.jpg",
"link": "http://www.facebook.com/platform",
"likes": 3922010,
"category": "Product/service",
"website": "http://developers.facebook.com",
"username": "platform",
"founded": "2007",
"company_overview": "Facebook Platform enables anyone to build social apps on Facebook and the web.",
"mission": "To make the web more open and social.",
"about": "We're building the social web. Get the latest here: developers.facebook.com ",
"talking_about_count": 74536
}
較長的答案,如果你使用的是特定用戶的訪問令牌來執行代表他們的行動,你可能會考慮要求「脫機訪問」,使該令牌不會過期。有關如何獲得此權限的更多信息,請參閱https://developers.facebook.com/docs/reference/api/permissions/。
離線訪問已被棄用,雖然因爲Facebook喜歡在屁股疼痛和打破東西。 – bkaid
這將打破事情的肯定。 – mattbornski