0) { debug('Key '.$keyid.' added'); reply(S_OK, $ci['secret'], $client, $nonce); } else { reply(S_BACKEND_ERROR, $ci['secret'], $client, $nonce); exit; } function reply($status, $apiKey, $client_id, $nonce, $info=null) { global $tokenId; if ($status == null) { $status = S_BACKEND_ERROR; } date_default_timezone_set('UTC'); $timestamp = date('Y-m-d\TH:i:s\ZZ', time()); //// Prepare the response to the user // $respParams = 'status='.$status.'&t='.$timestamp; // Generate the signature debug('API key: '.$apiKey); // API key of the client debug('Signing response: '.$respParams); // the TRUE at the end states we want the raw value, not hexadecimal form $hmac = hash_hmac('sha1', utf8_encode($respParams), $apiKey, true); //outputToFile('hmac', $hmac, "b"); // now take that byte value and base64 encode it $hmac = base64_encode($hmac); echo 'h='.$hmac.PHP_EOL; if ($info != null) { echo 'info='.$info.PHP_EOL; } echo 'nonce='.$nonce.PHP_EOL; echo 'status='.$status.PHP_EOL; echo 't='.$timestamp.PHP_EOL; echo PHP_EOL; } // End reply ?>