0
我想獲得所有喜歡帖子的ID。所以我開始循環瀏覽JSON對象,這很好。但是,我怎樣才能分離不同的職位喜歡,並將他們推到一個數組?將對象從圖形api中推入數組json with for循環for循環(facebook javascript sdk/open graph)
繼承人我的代碼:
var posts = data.posts.data.length; // how much posts (4)
var likedIDs = [];
for (var i = 0; i < posts; i++) {
var likes = data.posts.data[i].likes.data.length; //how much likes the post got
for(var j = 0; j < likes; j++){
likedIDs.push(data.posts.data[i].likes.data[j].id); //push liked IDs into array
}
}
我的結果是現在:
["100002767544234", "100002240698218", "100002186226181", "661093262", "100002965256572", "100000484302816", "1328033466", "100002965256572", "100000433187588", "100001859514071", "510954562300442", "1534181150", "100000433187588", "1534181150", "100000470102176", "231605130289758", "1328033466", "661093262", "100002186226181", "100002240698218", "1007746467", "100000433187588", "1216261931", "661093262", "1313025972", "100002240698218", "1534181150", "661093262", "100000328468050", "100001350606484", "100002767544234", "100000306728917", "1534181150", "100000328468050", "1216261931", "661093262", "100002240698218", "100000502074422", "100002559952817", "100000328468050", "100000484302816", "1802439459", "100002240698218", "1328033466"]
現在每一個曾經喜歡的具體崗位ID是在陣列中,但我需要他們分隔通過郵政索引或像這樣的對象:
[["1313025972", "100002240698218", "1534181150"],["1313025972", "100002240698218", "1534181150"],["1313025972", "100002240698218"],["1313025972"]]
我需要他們檢查登錄的fb用戶是否已經喜歡該帖子。
任何想法? THX提前和我的壞englisch
謝謝了很多!這很好:) –