3v4l.org

run code in 300+ PHP versions simultaneously
<?php //Enter your code here, enjoy! class ICObenchAPI { private $privateKey = '196c979a-e3a5-40cc-8bf8-55edbb4af14b'; private $publicKey = '570d742e-21c0-4a8b-9f13-fbc30f00b804'; private $apiUrl = 'https://icobench.com/api/v1/'; public $result; public function getICOs($type = 'all', $data = ''){ return $this->send('icos/' . $type, $data); } public function getICO($icoId, $data = ''){ return $this->send('ico/' . $icoId, $data); } public function getOther($type){ return $this->send('other/' . $type, ''); } private function send($action, $data){ $dataJson = json_encode($data); echo $sig = base64_encode(hash_hmac('sha384', $dataJson, $this->privateKey, true)); echo '*'; echo strlen($dataJson); echo '*'; echo $this->publicKey; echo '*'; echo $sig; echo '*'; echo $dataJson; $ch = curl_init($this->apiUrl . $action); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $dataJson); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json', 'Content-Length: ' . strlen($dataJson), 'X-ICObench-Key: ' . $this->publicKey, 'X-ICObench-Sig: ' . $sig) ); $reply = curl_exec($ch); $ff = $reply; $reply = json_decode($reply,true); if(isset($reply['error'])){ $this->result = $reply['error']; return false; }else if(isset($reply['message'])){ $this->result = $reply['message']; return true; }else if(isset($reply)){ $this->result = json_encode($reply); return true; }else{ $this->result = htmlspecialchars($ff); return false; } } public function result(){ return $this->result; } } $api = new ICObenchAPI(); $api->getICOs("all"); echo $api->result;

preferences:
51.65 ms | 402 KiB | 5 Q