4
votes

I am making some PHP code which takes a given search phrase and url and searches through the google search results until it finds the url (only first 100 results). My problem is, this is only working for the US. I have tried adding the "&cr=" option, but it still on returns US results.

The full URL I am using for the request is:

https://www.googleapis.com/customsearch/v1?key=API_KEY&cx=CX_VALUE&q=KEYWORD&cr=COUNTRY&alt=JSON

Does anyone have any experience with this? I want to be able to see UK results. Tried inserting &cr=countryUK , but still only does US results.

Thanks :)

Regards, Stian

1
Does anyone know another forum where I could ask this, and possibly get an answer?Stian
have you been able to solve this issue?byte_slave
Nope, I haven't resolved it yet.. The google API doesn't seem to support any country parameters in the REST request.Stian

1 Answers

4
votes

Use the gl=<country code> param to limit it to your country of choice (so gl=gb for the uk).

More info here:

http://googleajaxsearchapi.blogspot.com/2009/10/web-search-in-your-country.html