$cross_site_api_base = 'https://zvini.com/cross-site-api-call/';
$cross_site_api_key = 'DPFvTPfRvNPLfVvR4...';
$method = 'someNamespace/someMethod';
$params = [
'cross_site_api_key' => $cross_site_api_key,
'param1' => 'value1',
'param2' => 'value2',
];
$ch = curl_init($cross_site_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);
}
$response = json_decode($response);