API Examples

PHP DNS API code sample

PHP Example

The following example code can be used as a framework to build an interface to the Conexim API in PHP.
<?php $secretkey = 'b6909ec85ac47341208e3aac08d6b25b2ab7cf50c8c3ad1143898a3c5c2e94199d7cec4...'; $keyid = '530c0ce4471fa'; $server = 'https://api.conexim.net'; $action = '/api/dns/v1/domains'; $verb = 'GET'; $params = array(); ksort($params); $utimeGMT = (int)gmdate('U'); $sigString = $keyid . "\n" . $utimeGMT . "\n" . $verb . "\n" . $action . "\n" . http_build_query($params); $sig = base64_encode(hash_hmac("sha256", $sigString, $secretkey, true)); $ch = curl_init($server . $action); $headers[] = 'Content-type: application/json'; $headers[] = 'Authorization: CONEXIM ' . $keyid . ':' . $sig; $headers[] = 'Conexim-Time: ' . $utimeGMT; $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_CUSTOMREQUEST => $verb, CURLOPT_POSTFIELDS => json_encode($params), CURLOPT_RETURNTRANSFER => true, ); curl_setopt_array($ch, $options); $result = curl_exec($ch); $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "Response Code: " . $responseCode . "\n"; echo "Response Data:\n"; print_r(json_decode($result)); ?>

API Calls Python Example