Author

Topic: Havelock Api help needed can get any results (Read 677 times)

sr. member
Activity: 490
Merit: 250
April 27, 2014, 08:59:25 PM
#6
Yes, but don't belive they will give me answer (not so far), I contacted them as well.
Have you received a reply? It's been a few weeks already.
full member
Activity: 150
Merit: 100
Yes, but don't belive they will give me answer (not so far), I contacted them as well.
sr. member
Activity: 266
Merit: 250
Do they provide support
full member
Activity: 150
Merit: 100
Yes I have from phpinfo():

json

json support   enabled
json version   1.2.1
sr. member
Activity: 490
Merit: 250
Do you have the json extension installed?
full member
Activity: 150
Merit: 100
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?

$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'])));

?>
Jump to: