bitz: prevent api error if data field is not present

This commit is contained in:
Tanguy Pruvot 2018-09-07 09:03:55 +02:00
parent cc456814c5
commit b6aa81390a

View file

@ -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());
}