Skip to content

Instantly share code, notes, and snippets.

@jorilallo
Created January 29, 2015 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorilallo/7b9b2e632964c5fbf827 to your computer and use it in GitHub Desktop.
Save jorilallo/7b9b2e632964c5fbf827 to your computer and use it in GitHub Desktop.
Coinbase Exchange signing with PHP
<?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