$key = 'APIKEY';
$secret_key = 'APISECRET';
$timestamp = time();
$signature = hash_hmac('sha1', $timestamp, $secret);
should be
$signature = hash_hmac('sha1', $timestamp, $secret_key);
your $secret is not defined. unless you just didn't paste it that would cause the error