Answer the question
In order to leave comments, you need to log in
How to send API link via POST request?
Hello.
--
I have an API link that writes the passed parameters to a database table.
I did it according to the php documentation (I can't use curl)
The principle I use is this:
...
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question