Jump to content

AKiwi92

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by AKiwi92

  1. Okay so just to help others out here is the PHP snippet that I managed to get working making a cURL request to the Spektrix V3 API <?php $date = new DateTime('NOW'); $date = $date->format('D, d M Y H:i:s \G\M\T'); $LoginName = "API USERNAME"; $SecretKey = "API SECRET KEY"; $StringToSign = "GET\nFULL URL YOU ARE QUERYING\n".$date; $StringToSignEncoded = utf8_encode( $StringToSign ); $SecretBase64Decoded = base64_decode($SecretKey); $sha1 = hash_hmac('sha1', $StringToSignEncoded, $SecretBase64Decoded,true); $Signature = base64_encode($sha1); $Authorization = "SpektrixAPI3 " . $LoginName . ":" . $Signature; $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'FULL URL YOU ARE QUERYING', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'GET', CURLOPT_HTTPHEADER => array( 'Authorization:'.$Authorization, 'Date:'.$date ), )); $response = curl_exec($curl); var_dump($response); curl_close($curl); ?> I hope this helps someone else who was stuck on this one!
×
×
  • Create New...