<?php function Bter_query ($path, array $req = Array ()) {//API settings, add your Key and Secret at here $key = '; $s Ecret = "; Generate a nonce to avoid problems with 32bits systems $MT = Explode (", microtime ()); $req [' nonce '] = $mt [1].substr ($mt [0], 2, 6); Generate the POST data string $post _data = Http_build_query ($req, "', ' & '); $sign = Hash_hmac (' sha512 ', $post _data, $secret); Generate the extra headers $headers = Array (' KEY: '. $key, ' sign: ' $sign,); //!!! Please set Content-type to application/x-www-form-urlencoded if it's not the default value//Curl handle (Initialize if r equired) static $ch = null; if (Is_null ($ch)) {$ch = Curl_init (); curl_setopt ($ch, Curlopt_returntransfer, True); curl_setopt ($ch, Curlopt_ UserAgent, ' mozilla/4.0 (compatible; Bter PHP Bot; '. Php_uname (' a '). '; php/'. Phpversion (). ') ' ); } curl_setopt ($ch, Curlopt_url, ' https://bter.com/api/'. $path); curl_setopt ($ch, Curlopt_postfields, $post _data); curl_setopt ($ch, Curlopt_httpheader,$headers); curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); Run the query $res = curl_exec ($ch); if ($res = = = False) throw new Exception (' Curl error: '. Curl_error ($ch)); Echo $res; $dec = Json_decode ($res, true); if (! $dec) throw new Exception (' Invalid data: '. $res); return $dec; } function Get_top_rate ($pair, $type = ' BUY ') {$rate = 0;//Our curl handle (initialize if required) static $ch = null; if (Is_null ($ch)) {$ch = Curl_init (); curl_setopt ($ch, Curlopt_returntransfer, True); curl_setopt ($ch, Curlopt_useragent, ' mozilla/4.0 ( Compatible Bter PHP Bot; '. Php_uname (' a '). '; php/'. Phpversion (). ') ' ); } curl_setopt ($ch, Curlopt_url, ' https://bter.com/api/1/depth/'. $pair); curl_setopt ($ch, Curlopt_ssl_verifypeer, FALSE); Run the query $res = curl_exec ($ch); if ($res = = = False) throw new Exception (' Could not get reply: '. Curl_error ($ch)); Echo $res; $dec = Json_decode ($res, true); if (! $dec) throw new Exception (' Invalid data: '. $res); if (Strtoupper ($type) = = ' BUY ') {$r = $dec[' bids '][0]; $rate = $r [0]; } else {$r = end ($dec [' asks ']); $rate = $r [0];} return $rate; } try {//Example 1:get funds Var_dump (bter_query (' 1/private/getfunds '));//Example 2:place a buy order $pair = ' Ltc_b TC '; $type = ' buy '; $rate = Get_top_rate ($pair, $type) * 1.01; Var_dump (' 1/private/placeorder ', array (' pair ' + ' $pair ', ' type ' = ' $type ', ' rate ' = ' $rate ', ' amo Unt ' = ' 0.01 ',))); Example 3:cancel an order Var_dump (Bter_query (' 1/private/cancelorder ', Array (' order_id ' = 125811)); Example 4:get order status Var_dump (Bter_query (' 1/private/getorder ', Array (' order_id ' = 15088)); Example 5:list all open orders Var_dump (bter_query (' 1/private/orderlist ')); } catch (Exception $e) {echo "Error:". $e->getmessage ();}? >