我使用Facebook的Javascript SDK來獲得的收件箱的郵件,到目前爲止,我能得到他們,這將轉化爲一個JSON對象無法JSON對象
function getMsgs() { FB.api( "/me/inbox", function (response) { if (response && !response.error) { var result = JSON.stringify(response); document.getElementById("msgs").innerHTML="<pre>"+result+"</pre>"; } } ); }
什麼就得到一個特定的值我最終得到的是這樣的:
{
"data":[
{
"id":"15986833470221166",
"to":{
"data":[
{
"id":"7888047207869023",
"name":"My Name"
},
{
"id":"101530783476778608",
"name":"Friend Name"
}
]
},
"updated_time":"2015-02-08T03:09:02+0000",
"unread":5,
"unseen":0,
"comments":{
"data":[
{
"id":"159268645347021166_1421118060",
"from":{
"id":"7888047207869023",
"name":"My Name"
},
"message":"blah blah blah",
"created_time":"2015-01-13T03:01:00+0000"
},
{
"id":"159268645347021166_1421118060",
"from":{
"id":"7888047207869023",
"name":"My Name"
},
"message":"blah blah blah",
"created_time":"2015-01-13T03:01:16+0000"
},
{
"id":"159268645347021166_1421118060",
"from":{
"id":"101530783476778608",
"name":"Friend Name"
},
"message":"blah blah blah",
"created_time":"2015-01-13T03:01:23+0000"
},
{
"id":"159268645347021166_1421118060",
"from":{
"id":"101530783476778608",
"name":"Friend Name"
},
"message":"blah blah blah",
"created_time":"2015-01-13T03:01:30+0000"
},
{
"id":"159268645347021166_1421118060",
"from":{
"id":"101530783476778608",
"name":"Friend Name"
},
"message":"blah blah blah",
"created_time":"2015-02-08T03:09:02+0000"
}
],
"paging":{
"previous":"https://graph.facebook.com/v2.2/15986453474543021166/comments?access_token=TOKEN&limit=25&since=1423364314942&__paging_token=TOKEN&__previous=1",
"next":"https://graph.facebook.com/v2.2/15986453474543021166/comments?access_token=TOKEN&limit=25&until=142111148324060&__paging_token=TOEKN"
}
}
}
我想訪問'消息'值。我想創建一個數組來存儲這個JSON結構中的每個消息值。
你做可循環數據[0] .comments.data' – qtgye 2015-02-11 03:40:16