Convert php code to java for beter.com access - repost
$10-30 AUD
Terminado
Publicado hace más de 10 años
$10-30 AUD
Pagado a la entrega
I am working on a trading bot for [login to view URL] but I cannot get the code to work correctly. Their web page lists an example in php see [login to view URL]
What I like is the function bter_query php to be rewritten in java. The result should be that the function can be called and obtain the balance for the currency on the web site. I will supply the key and secret the function requires.
Thus the delivery for this project is a single java file that when run will obtain the balances from [login to view URL]
You are free to use additional free libraries like those supplied from Apache as required.
Below is the example from their web site. I have removed a few lines as they run examples not required. Hopefully it will still run in php and all you need to do is convert it to java.
<?php
function bter_query($path, array $req = array()) {
// API settings, add your Key and Secret at here
$key = '';
$secret = '';
// 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,
);
// 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, '[login to view URL]'.$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, '[login to view URL]'.$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'));
} catch (Exception $e) {
echo "Error:".$e->getMessage();
}
?>
Hi, I can convert the php code to java and get the balance for the currency. DO you want it as standalone Java application?
To brief about me, I have 6+ years of experience in Java/j2EE technologies with SCJP/SCBCD certification. Looking forward to work on this.
REgards
$30 AUD en 1 día
5,0 (16 comentarios)
4,6
4,6
7 freelancers están ofertando un promedio de $64 AUD por este trabajo
Hello,
I have read through your project and I am incredibly interested in taking on your project. I am an experienced developer with a diploma in the field of web development. I have been working in the field of web development for roughly 7 years. I take great pride in my work and deliver only the best quality.
My skill-set includes...
-PHP
-HTML5
-CSS
-Responsive Design
-Wordpress
I look forward to hearing from you and hopefully we will have the opportunity to work together.
Thank you,
Meagan S.