简体   繁体   English

如何从Facebook图形API中的给定图形URL获取数据

[英]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 这只是两步的事情

  1. Parse the next/previous URL from the response. 解析响应中的下一个/上一个URL。 You can do it yourself or one of the many libraries 您可以自己做,也可以做很多图书馆之一
  2. 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.

相关问题 JavaScript:如何使用API​​ Graph喜欢Facebook墙上的帖子(给定Facebook页面URL和Facebook帖子ID)? - JavaScript: How to like a Facebook wall post (given a Facebook page URL and a Facebook post id) using API Graph? 如何使用 UrlFetchApp.fetch(url, params) 在 Google Apps Script 中正确查询 Facebook Graph API? - How to query Facebook Graph API correctly in Google Apps Script using UrlFetchApp.fetch(url, params)? 如何在Graph API上从facebook Ads获取数据? - How to get data from facebook Ads on the Graph API? 如何从返回的Facebook图形API哈希中提取数据 - How to extract data from returned facebook graph api hash 如果在jQuery中给出了键,如何从API URL中获取数据? - How to fetch data from API url if key is given in jquery? 如何在C#中从Facebook图形API获取Facebook朋友 - How to get facebook friends from facebook graph api in c# 从 api 获取数据并在 Material UI 和 React 中设置图形的值 - Fetch data from api and set the values for the graph in Material UI and React facebook graph api确定用户是否喜欢url - facebook graph api determine if user likes url 使用Graph API Facebook获取视频源URL - Get Video Source URL with Graph API Facebook Facebook Graph API获取网址图片 - Facebook Graph API get picture of url
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM