I have a script that uses Google Custom Search API, iterating through multiple results pages.
https://www.googleapis.com/customsearch/v1?key=[[KEY]]&num=10&hl=en&start=0&cx=[[CX]]&q=%22bank%22&sort=date&googlehost=www.google.com
https://www.googleapis.com/customsearch/v1?key=[[KEY]]&num=10&hl=en&start=10&cx=[[CX]]&q=%22bank%22&sort=date&googlehost=www.google.com
https://www.googleapis.com/customsearch/v1?key=[[KEY]]&num=10&hl=en&start=20&cx=[[CX]]&q=%22bank%22&sort=date&googlehost=www.google.com
In all of the above examples, I get proper responses. The query response claims that there are 17,900 results to the search. When the script reaches start=100, however:
https://www.googleapis.com/customsearch/v1?key=[[KEY]]&num=10&hl=en&start=100&cx=[[CX]]&q=%22bank%22&sort=date&googlehost=www.google.com
I receive the following response (this is the JSON response transformed into a PHP object):
stdClass Object (
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => global
[reason] => invalid
[message] => Invalid Value
)
)
[code] => 400
[message] => Invalid Value
) )
This is despite the fact that the results I receive in start=90 claim that the next page exists:
"nextPage": [
{
"title": "Google Custom Search - \"bank\"",
"totalResults": "17900",
"searchTerms": "\"bank\"",
"count": 10,
"startIndex": 100,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "[[CX VALUE]]",
"sort": "date",
"googleHost": "www.google.com",
"hl": "en"
}
]
Playing around with the API shows that this invalid value error appears exactly when start=92. Furthermore, this is the exact page where this error appears for every keyword search. Any help with the issue would be appreciated. Is this because this is a free version of Google Custom Search?