Answer the question
In order to leave comments, you need to log in
Symfony 4 - how to make a POST request to someone else's (external) API?
having read the documentation and did not become smarter, can anyone tell me how to send a request to posts with a couple of parameters and get JSON back?
http://symfony.com/doc/2.6/book/http_fundamentals.html#requests-and-responses-in-symfony
Answer the question
In order to leave comments, you need to log in
For example line 145
https://gist.github.com/Kirill-Gorelov/50e412984b1...
Try using cURL like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'www.someapi.com?param1=A¶m2=B');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json')); // Assuming you're requesting JSON
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
// If using JSON...
$data = json_decode($response);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question