Created
January 29, 2015 21:17
-
-
Save jorilallo/7b9b2e632964c5fbf827 to your computer and use it in GitHub Desktop.
Coinbase Exchange signing with 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
<?php | |
class CoinbaseExchange { | |
public function __construct($key, $secret, $passphrase) { | |
$this->key = $key; | |
$this->secret = $secret; | |
$this->passphrase = $passphrase; | |
} | |
public function signature($request_url='', $body='', $timestamp=false, $method='GET') { | |
$body = is_array($body) ? json_encode($body) : $body; | |
$timestamp = $timestamp ? time() : $timestamp; | |
$what = $timestamp.$method.$request_url.$body; | |
return base64_encode(hash_hmac("sha256", $what, base64_decode($this->secret), true)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment