3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Bitfinex { private $api_key; private $api_secret; private $api_version; private $base_url = 'https://api.bitfinex.com'; public function __construct($api_key, $api_secret, $api_version = 'v1') { $this->api_key = $api_key; $this->api_secret = $api_secret; $this->api_version = $api_version; } public function get_balances() { $request = '/' . $this->api_version . '/balances'; echo $request; $data = array( 'request' => $request, 'options' => array() ); return $this->send_signed_request($data); } private function prepare_header($data) { $data['nonce'] = 144800329405116; //(string) number_format(round(microtime(true) * 100000),0,'.',''); echo $data; echo '<br/>'; echo "Json encode"; echo '<br/>'; echo json_encode($data); echo '<br/>'; $payload = base64_encode(json_encode($data)); $signature = hash_hmac('sha384', $payload, $this->api_secret); echo "payload "; echo $payload; echo " sig "; echo $signature; echo " "; return array( 'X-BFX-APIKEY: ' . $this->api_key, 'X-BFX-PAYLOAD: ' . $payload, 'X-BFX-SIGNATURE: ' . $signature ); } private function send_signed_request($data) { $ch = curl_init(); $url = $this->base_url . $data['request']; // echo $url; $headers = $this->prepare_header($data); curl_setopt_array($ch, array( CURLOPT_URL => $url, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_POSTFIELDS => "" )); $information = curl_getinfo($ch); echo $information; // echo $result; if( !$result = curl_exec($ch) ) { echo "NO <br/>"; return false; } else { echo "YES <br/>"; return json_decode($result, true); } } } $la = new Bitfinex('1', 'E8AeyGATKUFmWLSWLGSYznRFmaoboxgGPzmRzgn0G8x', '1'); $drek = $la->get_balances(); //$information = curl_getinfo($curl_exect); echo '<br/>'; echo 'Recived data'; //echo $drek; ?>
based on IOaje
Output for 7.0.0 - 7.2.0
/1/balances Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/ae1FW:60 Stack trace: #0 /in/ae1FW(27): Bitfinex->send_signed_request(Array) #1 /in/ae1FW(97): Bitfinex->get_balances() #2 {main} thrown in /in/ae1FW on line 60
Process exited with code 255.
Output for 5.5.0 - 5.6.28
/1/balances Fatal error: Call to undefined function curl_init() in /in/ae1FW on line 60
Process exited with code 255.