Home php 403 when requesting in Geocoder API Yandex.Cart

403 when requesting in Geocoder API Yandex.Cart

Author

Date

Category

Trying to get geo coordinates from PHP script:

$ params = array (
    'geocode' = & gt; 'Moscow, ul. Lion Tolstoy, 16 ', // Address
    'Format' = & gt; 'json', // response format
    'results' = & gt; 1, // number of output results
    'Key' = & gt; 'De30B30E-ABA5-4091-A796-XXX' // Your Key API
  );
  $ response = json_decode (file_get_contents ('https://geocode-maps.yandex.ru/1.x/?'. http_build_Query ($ params, '', '& amp;)));
  if ($ response- & gt; response- & gt; geoobjectCollection- & gt; metadataproperty- & gt; geocoderresponsemetadata- & gt; found & gt; 0) {
    Echo $ Response- & gt; Response- & gt; geoobjectCollection- & gt; FeatureMember [0] - & gt; geoobject- & gt; point- & gt; pos;
  } else {
    echo 'nothing found & lt; br & gt;';
  }

Get “Nothing found”.

Display the URL with the parameters, and insert it into the address bar. We get:

{"Statuscode": 403, "error": "forbidden", "message": "Key Is Required" }

What kind of chores us that we do not indicate the API key, although we indicated it.

Display Print_R ($ Response) is generally empty! file_get_contents With another URL running. I conclude, maybe incorrect –

file_get_contents (
 'https://geocode-maps.yandex.ru/1.x/?' .
  http_build_Query ($ params, '', '& amp;)
)

does not work, although the HTTP request is formed correctly. It is completely incomprehensible why when copying an HTTP request and sending it through the browser string, we receive a message that we do not specify the key. The Yandex developer’s office see that the API key is active.

There are considerations on this account?


Answer 1, Authority 100%

As far as I see – not Key , and apikey

https://tech.yandex.ru/ Maps / Geocoder / Doc / Desc / Concepts / Input_params-Docpage /

https://geocode-maps.yandex.ru/1.x/?pikey=wash API key & amp; Geocode = Moscow, + Tverskaya + Street, + House + 7

Try the minimal simple request from their documentation with your key and debug your code on the basis of the results.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions