Hi Guys,
I was starting to use havelock investments API based on Havelock Investments example.
I try to use their example (code below) but don't get any results.
I have instaled curl to php, generally script is working as I add dummy line and can see it.
Any help?
<?php
$key="pasted key here";
$ch=curl_init();
$url="
https://www.havelockinvestments.com/api/index.php";
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
function api($cmd,$vars=array()) {
global $ch;
global $url;
global $key;
curl_setopt($ch,CURLOPT_URL, $url);
$fields=array("key"=>$key,
"cmd"=>$cmd);
$fields_string="";
$fields=array_merge($fields,$vars);
foreach($fields as $k=>$value) { $fields_string .= $k.'='.urlencode($value).'&'; }
$fields_string=rtrim($fields_string, '&');
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$ret=curl_exec($ch);
print_r("dummy "); //----added for testing and it is visible so server is working
return json_decode($ret,true);
}
phpinfo();
print_r(api("ticker"));
print_r(api("tickerfull",array("symbol"=>"HIF")));
print_r(api("balance"));
print_r(api("portfolio"));
print_r(api("orderbook",array("symbol"=>"HIF")));
$o=api("ordercreate",array("symbol"=>"HIF", "action"=>"buy", "price"=>0.1, "units"=>10));
print_r($o);
print_r(api("ordercancel",array("id"=>$o['order'])));
?>