Skip to content

Commit

Permalink
bitz: prevent api error if data field is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Sep 7, 2018
1 parent cc45681 commit b6aa813
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion web/yaamp/core/exchange/bitz.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@ 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);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
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());
}

0 comments on commit b6aa813

Please sign in to comment.