3v4l.org

run code in 300+ PHP versions simultaneously
<?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; 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 => "" )); // 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', '1', '1'); $drek = $la->get_balances(); echo '<br/>'; echo 'Recived data'; echo $drek; ?>
Output for git.master, git.master_jit, rfc.property-hooks
/1/balances Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/6elgQ:56 Stack trace: #0 /in/6elgQ(27): Bitfinex->send_signed_request(Array) #1 /in/6elgQ(90): Bitfinex->get_balances() #2 {main} thrown in /in/6elgQ on line 56
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.89 ms | 401 KiB | 8 Q