2016-07-07 33 views
-1

我試圖通過流星:如何從Facebook網址獲得JSON

$.getJSON("https:graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) { 
    }); 

得到用戶的生日,但不幸的是我對如何獲得生日本身不知道,因爲它給我回這個巨大的對象我不知道如何處理它:

任何人都可以請幫助我。我正在查看類似的問題,但不幸的是,建議使用here的$ .getJSON同步已被棄用。問題herehere也沒有真正幫助。在此先感謝:)

回答

1

要在您的代碼中獲得生日,您需要導航到您的JSON數據的對象。

`$.getJSON("https://graph.facebook.com/me?fields=birthday&access_token="+accessToken, function(data) { 
    var birthday = data.birthday // This is your birthday 
    var id = data.id // This is your Fb ID 

    console.log('Hi! '+ id +'. Your birthday is '+ birthday) 
});` 
+0

哦,這比我想象的容易。非常感謝你@Rui Costa – janjackson