wickywills
7/13/2018 - 10:51 AM

Connecting to an API

You can also use "Postman"

$theAPIkey  = ''; // x-api-key
$theAPIapp  = ''; // x-api-application
$theURL   = '';

$timeout = 5; // set to zero for no timeout
$ch = curl_init();

curl_setopt ($ch, CURLOPT_URL, $theURL);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array(
    'x-api-key' . $theAPIkey,
    'x-api-application' . $theAPIapp
));
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

$response = curl_exec($ch);

echo '<pre>';
print_r($response);
echo '</pre>';

curl_close($ch);