Answer the question
In order to leave comments, you need to log in
How to make a request through the REST API and get a response?
You need to make a request to a third-party server using the REST API.
I found only information on how to make a REST API server and respond to requests.
the request should look like this:
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Token " \
-H "X-Secret: " \
-d '[ "here is the info that send" ]' \
https://ru.ru
In the future, you need to send several hundred such requests, get a response and extract the necessary data from it.
Answer the question
In order to leave comments, you need to log in
Used yiisoft/yii2-httpclient.
The code was something like this:
$client = new Client();
$response = $client->createRequest()
->setFormat(Client::FORMAT_JSON)
->setMethod('post')
->setUrl('https://ru.ru')
->setHeaders(['Content-Type' => 'application/json'])
->addHeaders(['Authorization' => ''])
->addHeaders(['X-Secret' => ''])
->setData(['data' => $data])
->send();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question