- create a new file with code below:
<?php
function httpPost($url, $data)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Authorization' => 'someAuthorization',
'x-api-key' => 'somekey',
'Content-Type' => 'application/json'
]);
$response = curl_exec($curl);
curl_close($curl);
return $response;
}
$response = httpPost('https://url', []);
echo $response;
- go to the path of this file by terminal
- run
php yourfilename.php