How does facebook graph api pagination work and how does iterate facebook user with it?

SO. I ran into a problem, and finding time on the Internet via the Internet did not help many, I thought that it was always a good option. I have a facebook call to GraphAPI to force facebook users to log in as shown below:

dynamic myFeed = await fb.GetTaskAsync(
                    ("me/feed?fields=id,from {{id, name, picture{{url}} }},story,picture,link,name,description," +
                    "message,type,created_time,likes,comments")
                    .GraphAPICall(appsecret_proof));

Above, help me return some of the last messages that the user posted after some time 21 or 22 messages, but not a complete list of user messages. I was looking for a way to iterate through a user feed through facebook pagination. In the end, I found this solution that works by facebook page.

dynamic myFeed = await fb.GetTaskAsync(
                    ("me/feed?fields=id,from {{id, name, picture{{url}} }},story,picture,link,name,description," +
                    "message,type,created_time,likes,comments")
                    .GraphAPICall(appsecret_proof), new {limit = "1000", offset = "21" });

, , , , . ? , .

P.S: Facebook # SDK.

Update1: . , facebook . , # facebook sdk Next Edges, , ? PS: API facebook, , , , , , - , facebook # SDK, Facebook # SDK .

+4
2

, , , API CAlls facebook . , , , facebook, , facebook pagination edge. /, , facebook while. (facebook access_token + (facebook appsecret_proof), :

var appsecret_proof = access_token.GenerateAppSecretProof();
var fb = new FacebookClient(access_token);

: facebook access_token HttpContext.

facebook API 25 :

dynamic myFeed = await fb.GetTaskAsync(
                    ("me/feed?fields=id,from {{id, name, picture{{url}} }},story,picture,link,name,description," +
                    "message,type,created_time,likes,comments")
                    .GraphAPICall(appsecret_proof));

API Call Json, Model View, :

var postList = new List<FacebookPostViewModel>();
    foreach (dynamic post in myFeed.data)
       {
         postList.Add(DynamicExtension.ToStatic<FacebookPostViewModel>(post));
       }

, , , , , facebook, . a string NextPageUri , :

string NextPageURI = string.Empty;

, , . , View Model , , :

while (myFeed.paging != null && myFeed.paging.next != null)
                {
                    NextPageURI = myFeed.paging.next;
                    var nextURL = GetNextPageQuery(NextPageURI, access_token);
                    dynamic nextPagedResult = await fb.GetTaskAsync(nextURL.GraphAPICall(appsecret_proof));
                    foreach (dynamic post in nextPagedResult.data)
                    {
                        postList.Add(DynamicExtension.ToStatic<FacebookPostViewModel>(post));
                    }
                }

. . , , , 30k, 10 , .

+1

:

- "", , , ,
- "", " " " "
- "",

API node , . , , .

3 :


, . , . , , , . , .

, , JSON:

{
  "data": [
     ... Endpoint data is here
  ],
  "paging": {
    "cursors": {
      "after": "MTAxNTExOTQ1MjAwNzI5NDE=",
      "before": "NDMyNzQyODI3OTQw"
    },
    "previous": "https://graph.facebook.com/me/albums?limit=25&before=NDMyNzQyODI3OTQw"
    "next": "https://graph.facebook.com/me/albums?limit=25&after=MTAxNTExOTQ1MjAwNzI5NDE="
  }
}

, "" ( ). , . , , UPSERT (, ).

Unix, .

, , JSON:

{
  "data": [
     ... Endpoint data is here
  ],
  "paging": {
    "previous": "https://graph.facebook.com/me/feed?limit=25&since=1364849754",
    "next": "https://graph.facebook.com/me/feed?limit=25&until=1364587774"
  }
}

, . , FaceBooks edge.

, . , .

, Offset - , . :

API. , , / , .

FB API.

https://developers.facebook.com/docs/graph-api/overview/
https://developers.facebook.com/docs/graph-api/using-graph-api/

+5

All Articles