S
S
Sergey2016-03-25 10:06:35
PHP
Sergey, 2016-03-25 10:06:35

In what format should data be transmitted via api?

I am making an API for a site in PHP, where you need to transfer data not only key-value, but also data arrays.
For example, I got the following request:

http://www.site.ru/api?token=32b4cecdadfe9052f9f1248d26bc4d19&method=contact_add&name=Максим&surname=Петров&property[skype]=petrovm&property[phone][]=79851234567&property[phone][]=79855554477

I get the data from the $_REQUEST array The
question is whether I'm doing it right or is it better to send the data in JSON format? For example like this:
http://www.site.ru/api?token=32b4cecdadfe9052f9f1248d26bc4d19&method=contact_add&data={name:"Максим", surname:"Петров",property:{skype:"petrovm", phone:["79851234567",  "79855554477"]}}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-03-25
@SashaSkot

Read here , here , more here and, of course, here

A
Alexander Wolf, 2016-03-25
@mannaro

Nite, not right. If you add a user with this command, then accept it using the POST method. But send the request body in JSON.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question