[英]How to fetch data from given graph URL in facebook graph API
Here is the Javascript: 这是Javascript:
The purpose of this code is to get Number of user's posts in last 3 Months. 这段代码的目的是获取最近3个月的用户帖子数。
FB.api('/me/photos?fields=created_time&since=2013-03-28', function(response){
dLen = response.data.length;
if(!response.paging.next){
dLenContent = "<div><span class='left'>"+i+++".</span><span class='mid'> Number of times tagged in photos: </span><span class='right'>"+dLen+"</span></div>";
}
else{
nextURL = response.paging.next;
while(nextURL){
graphURL = nextURL;
---------------------------------------
---How to fetch data from next page(graphURL)?---
---------------------------------------
dLen = dLen + response.data.length;
nextURL = response.paging.next;
}
}
pInfo = document.getElementById("personalInfo");
pInfo.innerHTML += dLenContent;
});
In case there is next page, the else part of the code will be executed. 如果有下一页,则将执行代码的else部分。 In that else part, I have written one while loop which will be active until the is next page in the object we get. 在其他部分,我编写了一个while循环,该循环将一直有效,直到获得对象的下一页为止。
I want to know get data of "response.paging.next"? 我想知道获取“ response.paging.next”数据吗?
This is just a 2 steps thing 这只是两步的事情
With the timestamp parsed, just call your function recursively and "since" in the Graph URL. 解析了时间戳后,只需递归调用函数,然后在Graph URL中“自”即可。
function getFBData(date) { FB.api('/me/photos?fields=created_time&since=' + date, function(response){ var pager = "parse the paging data from facebook" getFBData(pager); }); 函数getFBData(date){FB.api('/ me / photos?fields = created_time&since ='+日期,函数(响应){var pager =“从Facebook解析页面数据” getFBData(pager);}); } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.