How to write this php request:

POST http://testapi.novaposhta.ua/v2.0/json/Address/getCities HTTP / 1.1
Content-Type: application / json Host: testapi.novaposhta.ua
Content-Length: 102

{"modelName": "Address", "calledMethod": "getCities", "apiKey": "cc3537300145dfa379120a1143a15071"}

  • Get the data in json format you need. - Alexander Suetin

1 answer 1

Not quite clear question. But still try to answer.

  1. To send requests to the server from the client (browser) are used:

  2. In order to display the answer to the request in the browser it is used:

    • server programming in PHP or any other server language;
    • or if you want to accept and process the received data on the client (in the browser), use the AJAX technology provided in the jQuery library
    • or javascript language. Details: https://learn.javascript.ru/ajax
  3. To convert a java script object on the client side to the JSON format and vice versa, the following methods are used:

    • JSON.parse - reads objects from a string in JSON format.
    • JSON.stringify - turns objects into a string in JSON format, used when you need to transfer data via JavaScript over a network.

More details: https://learn.javascript.ru/json

  1. To convert a JSON object to a PHP variable and vice versa, the following functions are used on the server side:
    • json_decode - Decodes a JSON string
    • json_encode - Returns the JSON representation of the data.

More details: http://php.net/manual/ru/ref.json.php