$api_base = 'https://zvini.com/api-call/';
$api_key = 'DPFvTPfRvNPLfVvR4...';
$method = 'someNamespace/someMethod';
$params = [
'api_key' => $api_key,
'param1' => 'value1',
'param2' => 'value2',
];
$ch = curl_init($api_base.$method);
curl_setopt_array($ch, [
CURLOPT_POSTFIELDS => http_build_query($params),
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
die('ERROR: '.curl_error($ch));
}
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) !== 200) {
die('ERROR: '.$response);
}
$contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
if ($contentType === 'application/json') {
$response = json_decode($response);
}