Search in google maps api returns different values with Curl or guzzle

Asked

Viewed 54 times

1

I do the search in the google maps api with Curl or guzzle using php and returns me a different value than using the Postman or browser

ex:

$client = new Client();
    $res = $client->request('GET', $url,[
        'query' => [
            'type' => 'gas_station',
            'query' => 'Uberlandia,MG',
            'key' => 'MYKEY',
        ],
    ]);

it returns to me

{"html_attributions":[],"results":[],"status":"ZERO_RESULTS"}

but in the browser or in Postman returns me values by the url

https://maps.googleapis.com/maps/api/place/textsearch/json?type=gas_station&query=Uberlandia%2CMG&key=MYKEY

It’s not just this search, several return this error

$url = "https://maps.googleapis.com/maps/api/place/textsearch/json";
$client = new Client();
$res    = $client->request('GET', $url, [
  'headers' => [
    'User-Agent'    => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) 
     AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 
  Safari/537.36',
      'Accept'        => 'application/json',
    'Content-Type' => 'application/json',
    'cache-control' => 'no-cache',
],
'query' => [
    'type' => 'gas_station',
    'keyword' => 'posto,combustiveis',
    'query' => 'lago sul - Shi Sul Qi 05 Área Militar Vi Comar, S/n Parte - Lago Sul, Brasília - DF, Brasil',
    'key' => 'MYKEY'
],
]);

the direct search of this generates this url

https://maps.googleapis.com/maps/apiplace/textsearch/jsontype?type=gas_station&keyword=posto,combustiveis&query=lago+sul+-+Shi+Sul+Qi+05+%C3%81rea+Militar+Vi+Comar%2C+S%2Fn+Parte+-+Lago+Sul%2C+Bras%C3%Adlia+-+DF%2C+Brasil&key=MYKEY

I thought it was urlencode but the search for this value in Curl is the same as I play in Postman or Chrome but always by Curl or guzzle returns zero Results

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.