Created
May 8, 2019 09:58
-
-
Save alangrainger/608cf45c21055488f6f4ec4e245ed549 to your computer and use it in GitHub Desktop.
Signed OKEX requests with CURL and PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$time = round(microtime(true), 3); | |
$method = strtoupper($method); | |
$string = $time . $method . $endpoint; | |
$hash = hash_hmac('sha256', $string, $secret); | |
$hash = base64_encode(hex2bin($hash)); | |
$curl = curl_init(); | |
curl_setopt_array($curl, array( | |
CURLOPT_URL => 'https://www.okex.com' . $endpoint, | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_TIMEOUT => 10, | |
CURLOPT_CUSTOMREQUEST => $method, | |
CURLOPT_HTTPHEADER => array( | |
"OK-ACCESS-KEY: " . $apiKey, | |
"OK-ACCESS-SIGN: $hash", | |
"OK-ACCESS-TIMESTAMP: $time", | |
"OK-ACCESS-PASSPHRASE: " . $passphrase | |
) | |
)); | |
$result = curl_exec($curl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment