M
M
Max Ba2019-06-19 16:27:35
API
Max Ba, 2019-06-19 16:27:35

In what format should data be sent to the API server?

You can send a POST request with an array of data in the usual format

$post = [];
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

Or in JSON format
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));

Question: in what format is it accepted and better to transfer data to the server?
And is there any point in passing in json?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AUser0, 2019-06-19
@phpcoder81

And so, and so normal. Well, in JSON it's somehow more feng shui, or something.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question