Blogger search paging

39 views
Skip to first unread message

Leon Lucardie

unread,
Nov 13, 2012, 8:00:49 AM11/13/12
to google-api-obj...@googlegroups.com
I'm currently having an issue with the Blogger API Search call using the GTL library.

The search itself works fine. However, when I try to page through the results using a pageToken, I keep receiving the same result set. Whenever I call the Blogger API directly (using Fiddler for example) the API will return the proper pages. Is this an error in my code or is there something else going on?

Below is my code for the call (some variables omitted):

GTLServiceBlogger *service = [[GTLServiceBlogger alloc] init];

service.APIKey = MY_API_KEY;


GTLQueryBlogger *query = [GTLQueryBlogger queryForPostsSearchWithBlogId:BLOG_ID];

query.q = searchQuery;

query.pageToken = pageIdentifier;

[service executeQuery:query

        completionHandler:^(GTLServiceTicket *ticket,

                            GTLBloggerPostList *postList, NSError *error) {

            if(error == nil)

            {

                //Do something with result

            }

            else{

                //Display error

            }

            

            

            

            

        }];


Thanks in advance.


Greg Robbins

unread,
Nov 13, 2012, 10:53:43 AM11/13/12
to google-api-obj...@googlegroups.com
Your code snippet does not show how the next page token is being obtained.

Try using the library's http logging feature to inspect the server request and response.

Leon Lucardie

unread,
Nov 17, 2012, 4:38:05 PM11/17/12
to google-api-obj...@googlegroups.com
After checking the HTTP logs it seems the error lies with the Blogger API and not the objective-c library.

But just to be sure, here is how I retrieve my token and the HTTP logs.

I obtain my token like this:

/* <code to set up a search call> */

[service executeQuery:query

        completionHandler:^(GTLServiceTicket *ticket,

                            GTLBloggerPostList *searchResult, NSError *error) {

            [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];

            if(error == nil)

            {

                pageIdentifier = searchResult.nextPageToken;

                for(GTLBloggerPost *post in searchResult)

                {

                      //Do something with posts

                }

            }

            else{

                //Error handling

            }

            

            

            

            

        }];


As for HTTP logging:


This is the first request I make (without a page token):


2012-11-17 21:19:01 +0000

Request: POST https://www.googleapis.com/rpc?prettyPrint=false

Request headers:

  Accept: application/json-rpc

  Cache-Control: no-cache

  Content-Type: application/json-rpc; charset=utf-8

  User-Agent: <OMITTED>


Request body: (181 bytes)

{

  "id" : "gtl_3",

  "apiVersion" : "v3",

  "params" : {

    "q" : <OMITTED>,

    "key" : <OMITTED>,

    "blogId" : <OMITTED>

  },

  "method" : "blogger.posts.search",

  "jsonrpc" : "2.0"

}


Response: status 200

Response headers:

  Cache-Control: no-cache, no-store, max-age=0, must-revalidate

  Content-Encoding: gzip

  Content-Length: 39784

  Content-Type: application/json; charset=UTF-8

  Date: Sat, 17 Nov 2012 21:19:01 GMT

  Expires: Fri, 01 Jan 1990 00:00:00 GMT

  Pragma: no-cache

  Server: GSE

  X-Content-Type-Options: nosniff

  X-Frame-Options: SAMEORIGIN

  X-Xss-Protection: 1; mode=block


Response body: (202394 bytes)

{

  "id" : "gtl_3",

  "result" : {

    "kind" : "blogger#postList",

    "nextPageToken" : "CgkIChiB04DgrycQqq6Mr9WqpPIZ",

    "items" : [

       <POSTS OMITTED>

    ]

  }

}




And this is the request http log from the second call and onward with the page identifier added:


2012-11-17 21:19:27 +0000

Request: POST https://www.googleapis.com/rpc?prettyPrint=false

Request headers:

  Accept: application/json-rpc

  Cache-Control: no-cache

  Content-Type: application/json-rpc; charset=utf-8

  User-Agent: <OMITTED>


Request body: (224 bytes)

{

  "id" : "gtl_7",

  "apiVersion" : "v3",

  "params" : {

    "pageToken" : "CgkIChiB04DgrycQqq6Mr9WqpPIZ",

    "q" : "<OMITTED>,

    "key" : <OMITTED>,

    "blogId" : <OMITTED>

  },

  "method" : "blogger.posts.search",

  "jsonrpc" : "2.0"

}


Response: status 200

Response headers:

  Cache-Control: no-cache, no-store, max-age=0, must-revalidate

  Content-Encoding: gzip

  Content-Length: 39784

  Content-Type: application/json; charset=UTF-8

  Date: Sat, 17 Nov 2012 21:19:27 GMT

  Expires: Fri, 01 Jan 1990 00:00:00 GMT

  Pragma: no-cache

  Server: GSE

  X-Content-Type-Options: nosniff

  X-Frame-Options: SAMEORIGIN

  X-Xss-Protection: 1; mode=block


Response body: (202394 bytes)

{

  "id" : "gtl_7",

  "result" : {

    "kind" : "blogger#postList",

    "nextPageToken" : "CgkIChiB04DgrycQqq6Mr9WqpPIZ",

    "items" : [

       <POSTS OMITTED (Same items as last request)>

    ]

  }

}

-----------------------------------------------------------



Op dinsdag 13 november 2012 16:54:15 UTC+1 schreef Greg Robbins het volgende:
Reply all
Reply to author
Forward
0 new messages