开发者

How does paging work on the C# Facebook sdk

Cannot find any documentation for this...

Currently using the following code to get a list of my photos:

FacebookApp fb = new FacebookApp(accessToken);
dynamic test = fb.Get("me/photos");

I'm cycling through the first 25 photos that it returns. Simple.

Now how do it get it to return the next 25?

So far I've tried this:

FacebookApp fb = new FacebookApp(accessToken);
string query = "me/photos";

while (true)
{
    dynamic test = fb.Get(query);

    foreach (dynamic each in test.data)
    {
开发者_StackOverflow        // do something here
    }

    query = test.paging.next;
}

but it fails throwing:

Could not parse '2010-08-30T17%3A58%3A56%2B0000' into a date or time.

Do I have to use a fresh dynamic variable for every request, or am I going about this the wrong way completely?


Ended up finding this:

// first set (1-25)
var parameters = new ExpandoObject();
parameters.limit = 25;
parameters.offset = 0;

app.Api("me/friends", parameters);

// next set (26-50)
var parameters = new ExpandoObject();
parameters.limit = 25;
parameters.offset = 25;

app.Api("me/friends", parameters);


I also found you can use this.

// for the first 25 albums (in this case) 1-25
dynamic albums = client.Get("me/albums", new { limit = "25", offset = "0"});

// for the next 25 albums, 26-50
dynamic albums = client.Get("me/albums", new { limit = "25", offset = "25"});

Worked the same as you used above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜