From b6aa81390a6bef9405bae92af9c6dd32313ac474 Mon Sep 17 00:00:00 2001 From: Tanguy Pruvot Date: Fri, 7 Sep 2018 09:03:55 +0200 Subject: [PATCH] bitz: prevent api error if data field is not present --- web/yaamp/core/exchange/bitz.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/yaamp/core/exchange/bitz.php b/web/yaamp/core/exchange/bitz.php index 3740571..cd654e2 100644 --- a/web/yaamp/core/exchange/bitz.php +++ b/web/yaamp/core/exchange/bitz.php @@ -8,6 +8,7 @@ function bitz_api_query($method, $params='', $returnType='object') $url = "https://apiv2.bitz.com/Market/$method/"; if (!empty($params)) $url .= "?$params"; + $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); @@ -15,10 +16,12 @@ function bitz_api_query($method, $params='', $returnType='object') curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; BitZ API PHP client; '.php_uname('s').'; PHP/'.phpversion().')'); curl_setopt($ch, CURLOPT_ENCODING , ''); //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + $execResult = curl_exec($ch); if ($returnType == 'object') $ret = json_decode($execResult); else $ret = json_decode($execResult,true); - return $ret->data; + + return objSafeVal($ret,'data',array()); }