Can somebody please post an example of paging over BlogPosts by author that does not use the PHP API?

Views: 54

Reply to This

Replies to This Discussion

Here is a more general example, that just shows the URLs you are making the requests to and their output. Let me know if you need further clarification!

 

Your first request will be to a URL such as:

https://external.ningapis.com/xn/rest/apiexample/1.0/BlogPost/recen...

Which will give you a response with two blog posts:

{
  "success" : true,
  "anchor" : "N3MJuzFEQ0GMg_0AhimL_Qgwpc01BgdI",
  "firstPage" : true,
  "lastPage" : false,
  "entry" : [ {
    "id" : "3011345:BlogPost:24421",
    "author" : "0ci4t9uhf2yhh",
    "createdDate" : "2011-07-05T18:54:50.678Z"
  }, {
    "id" : "3011345:BlogPost:24419",
    "author" : "0ci4t9uhf2yhh",
    "createdDate" : "2011-07-05T17:59:45.159Z"
  } ],
  "resources" : {
  }
}


You then use the returned 'anchor' value in the next request to get the next two results:

https://external.ningapis.com/xn/rest/apiexample/1.0/BlogPost/recen...


{
  "success" : true,
  "anchor" : "N3MJuzFEQ0EJ044J9oVIDTPffyxCmZHP",
  "firstPage" : false,
  "lastPage" : false,
  "entry" : [ {
    "id" : "3011345:BlogPost:24608",
    "author" : "0ci4t9uhf2yhh",
    "createdDate" : "2011-07-05T17:39:42.675Z"
  }, {
    "id" : "3011345:BlogPost:24606",
    "author" : "0ci4t9uhf2yhh",
    "createdDate" : "2011-07-05T13:58:23.184Z"
  } ],
  "resources" : {
  }
}


Which gives another anchor value, which you use for the next two blog posts:

https://external.ningapis.com/xn/rest/apiexample/1.0/BlogPost/recen...

Devin,

 

Thanks for your reply. I did already figure out using the 'anchor' mechanism. However, I had been hoping that there was something available more similar to the old REST API. That is, you could say give me all the BlogPosts after date 'x' with 'from' and 'to' query string parameters. You could also receive a 'total_count' parameter so you knew for certain exactly how you would need to page over the data set. It's just far more transparent - you do actually refer to 'anchor' specifically as "opaque" in the documentation, after all.

 

I should also mention that, in my testing so far, the 'firstPage' and 'lastPage' parameters seemed to always both be set to 1.

Reply to Discussion

RSS

Blog Posts

Getting Started

Posted by Kyle Ford on October 13, 2010 at 8:00am 3 Comments

A Note on API Pricing

Posted by Phil McCluskey on October 1, 2010 at 8:55am 0 Comments

Welcome to Build!

Posted by Kyle Ford on September 30, 2010 at 8:30pm 1 Comment

Ning Status

© 2019   Created by Build Team.   Powered by

Badges  |  Report an Issue  |  Terms of Service