If we want to search google blogger posts with blogger APIs v3, then we should follow the documentation in here. But how can we integrate a date range in query parameter q
? i tried q=startDate:2016-01-01:T00:00:00+endDate:2017-09-05:T00:00:00
but it doesn't work.
I also tried to search posts from a certain date and after by using q=startDate:2016-01-01:T00:00:00
or q=startDate:"2016-01-01:T00:00:00"
or q=startDate:2016-01-01
but still doesn't work. The URL encoding is done properly because I tested with labels search like q=label:symbols|label:fonts
for searching posts which contain either the label symbols
or the label fonts
and it works just fine.
After a bit of search i finally find out that the answer was there but i was not looking carefully. When we want to search posts in a specific date range, we do not query the search:posts operation but the list:posts operation. For example if we want to search from
October 2, 2016
toSeptember 7, 2017
we send a request url of the following form:https://www.googleapis.com/blogger/v3/blogs/{blogID}/posts? startDate=2016-10-02T00:00:00z&endDate=2017-09-07T00:00:00z &callback=handleResponse&key={our_received_key}
handleResponse
is the callback function which is called when the response is received successfully. The above url query is ineffective because we receive also the body text of the post, which can impact performance. Also pagination must be used. The first is achieved by setting thefetchBodies=false
and the second is achieved by usingmaxResults
andpageToken
.A simplified script which encapsulates the above comments can be:
if the total number of posts is greater than the maxResults which is 10 in the example, then a
nextPageToken
will be sent which can be retrieved byresponse.nextPageToken
and stored in the next url query.https://www.googleapis.com/blogger/v3/blogs/35636577512/posts?startDate=2008-10-02T00:00:00z&endDate=2016-09-06T17:30:00z&pageToken=dfgdfRtdfdf234rT&fetchBodies=false&callback=handleResponse&key=RTza3456gfhf_Q345fgh'