Open mignav opened 7 years ago
I closed it oweing to the FBI warning on the page as I thought it was closed.
`Private API: Trade (Buy/Sell) Orders Checking on Past Orders API Query Method
Example Usage provided in Example.php
How to integrate: require_once('btce-api.php'); $BTCeAPI = new BTCeAPI({APIKEY},{APISECRET}[,Optional:{START_NOONCE}]);`
I assume you're doing this? ^^^
so get the result of your call like this:
$result = $BTCeAPI-> apiQuery(....);
then it should be $usdbalance = $result['return']['funds']['usd'];
Again, I put this code as you adviced:
$usdbalance = $result['return']['funds']['usd']; echo $usdbalance;
and it doesn't returned nothing - I mean parameter $usdbalance
doesn't correct and seems it is empty.
Can you please post your code that you're trying to execute. Replace any passwords and secrets with *****. I do not use this API anymore personally and it is difficult to help you if I cannot see what you are trying to do.
Yes, here it is (thank you for the help!):
<?php
/**
* Example Usage of the BTCe API PHP Class
*
* @author marinu666
* @license MIT License - https://github.com/marinu666/PHP-btce-api
*/
require_once('wex-api.php');
$BTCeAPI = new BTCeAPI(
/*API KEY: */ '**********************************',
/*API SECRET: */ '**********************************'
);
// Example getInfo
try {
// Perform the API Call
$getInfo = $BTCeAPI->apiQuery('getInfo');
// Print so we can see the output
print_r($getInfo);
} catch(BTCeAPIException $e) {
echo $e->getMessage();
}
// Example Custom query
try {
// Input Parameters as an array (see: https://btc-e.com/api/documentation for list of parameters per call)
$params = array('pair' => 'ppc_usd'); // Show info for the btc_usd pair
// Perform the API Query
print_r($BTCeAPI->apiQuery('ActiveOrders', $params));
} catch(BTCeAPIException $e) {
echo $e->getMessage();
}
// Making and canceling an order
try {
/*
* CAUTION: THIS IS COMMENTED OUT SO YOU CAN READ HOW TO DO IT!
*/
// $BTCeAPI->makeOrder(---AMOUNT---, ---PAIR---, BTCeAPI::DIRECTION_BUY/BTCeAPI::DIRECTION_SELL, ---PRICE---);
// $BTCeAPI->cancelOrder(---ORDER IR---);
// Example: to buy a bitcoin for $100
// $result = $BTCeAPI->makeOrder(1, 'ppc_usd', BTCeAPI::DIRECTION_BUY, 100);
$result = $BTCeAPI->makeOrder(0.1, 'ppc_usd', BTCeAPI::DIRECTION_BUY, 1.250);
// Example: to cancel the order
// $BTCeAPI->cancelOrder($result['return']['order_id']);
} catch(BTCeAPIInvalidParameterException $e) {
echo $e->getMessage();
} catch(BTCeAPIException $e) {
echo $e->getMessage();
}
// Example Public API JSON Request (Such as Fee / BTC_USD Tickers etc) - The result you get back is JSON RESTed to PHP
// Fee Call
$ppc_usd = array();
$ppc_usd['fee'] = $BTCeAPI->getPairFee('ppc_usd');
// Ticker Call
$ppc_usd['ticker'] = $BTCeAPI->getPairTicker('ppc_usd');
// Trades Call
$ppc_usd['trades'] = $BTCeAPI->getPairTrades('ppc_usd');
// Depth Call
$ppc_usd['depth'] = $BTCeAPI->getPairDepth('ppc_usd');
// Show all information
//print_r($ppc_usd);
echo '<br>test<br>:<br>';
$usdbalance = $result['return']['funds']['usd'];
echo $usdbalance;
?>
okay so its probably this section you are after
// Example getInfo try { // Perform the API Call $getInfo = $BTCeAPI->apiQuery('getInfo'); // Print so we can see the output print_r($getInfo); } catch(BTCeAPIException $e) { echo $e->getMessage(); }
It looks like you might be trying to buy something as well? that is what is being stored in result.
as it is, that is not storing the values like I was saying earlier, simple doing $result would not be enough.
Try using the getInfo variable instead, I think this should work:
$usdbalance = $getInfo['return']['funds']['usd'];
Yes, it is set to trying to buy new 0.1 PPC for 1.250 USD. But I need tell the script my account balance. That's why I need to transform Array ['usd'] -> to $usdbalance;
Basically, I need to make this as an Web-Bot, to : 1 - check my balance 2 - buy new PPC (or BTC) if cheap (let we say -20%) 3 - sell my PPC (or BTC ) if price is enough high (let we say +20%)
That's why I am doing this all :) Can you please help me with it? Thank you in advance!
ARE YOU ALIVE?
I work, getting several answers per day on a thread from anyone on github is good. If you send comments like that you are going to annoy people.
As I said earlier I believe this will be what you need, $usdbalance = $getInfo['return']['funds']['usd'];
And I also tell you my answer and now tell you again that "$usdbalance = $getInfo['return']['funds']['usd'];" does not return anything when you call at the and <? echo $usdbalance; ?>
.
Can you please try to use it yourself? I trying it a hundred times and it DOES NOT WORK as you tell me.
I wrote this years ago, I don't use btce anymore.
what does this return?
require_once('wex-api.php'); $BTCeAPI = new BTCeAPI( /*API KEY: */ '**********************************', /*API SECRET: */ '**********************************' ); // Example getInfo try { // Perform the API Call $getInfo = $BTCeAPI->apiQuery('getInfo'); // Print so we can see the output print_r($getInfo); } catch(BTCeAPIException $e) { echo $e->getMessage(); }
This returned the first part of same what it return with code above:
Array ( [success] => 1 [return] => Array ( [funds] => Array ( [usd] => *(my wex.nz usd balance)* [btc] => *(my wex.nz btc balance)* [ltc] => *(my wex.nz ltc balance)* [nmc] => *(my wex.nz nmc balance)* [rur] => *(my wex.nz rur balance)* [eur] => *(my wex.nz eur balance)* [nvc] => *(my wex.nz nvc balance)* [ppc] => *(my wex.nz ppc balance)* [dsh] => *(my wex.nz dsh balance)* [eth] => *(my wex.nz eth balance)* [bch] => *(my wex.nz bch balance)* [usdet] => *(my wex.nz usdet balance)* [btcet] => *(my wex.nz btcet balance)* [ltcet] => *(my wex.nz ltcet balance)* [ethet] => *(my wex.nz ethet balance)* [nmcet] => *(my wex.nz nmcet balance)* [nvcet] => *(my wex.nz nvcet balance)* [ppcet] => *(my wex.nz ppcet balance)* [dshet] => *(my wex.nz dshet balance)* [ruret] => *(my wex.nz ruret balance)* [euret] => *(my wex.nz wuret balance)* [bchet] => *(my wex.nz bchetbalance)* [zec] => *(my wex.nz zec balance)* ) [rights] => Array ( [info] => 1 [trade] => 1 [withdraw] => 0 ) [transaction_count] => 0 [open_orders] => 1 [server_time] => 1508783902 ) )
So how I can get only *(my wex.nz usd balance)*
?
...or that value after "Array ( [usd] =>
" ?
As you can see, it returned me all my balance values + server time + some trade and withdraw info, etc. but I need only USD value from my account.
ok try to change the print_r($getInfo) to print_r($getInfo["return"])
Now it returned
Array ( [funds] => Array ( [usd] => *(my wex.nz usd balance)* [btc] => *(my wex.nz btc balance)* [ltc] => *(my wex.nz ltc balance)* [nmc] => *(my wex.nz nmc balance)* [rur] => *(my wex.nz rur balance)* [eur] => *(my wex.nz eur balance)* [nvc] => *(my wex.nz nvc balance)* [ppc] => *(my wex.nz ppc balance)* [dsh] => *(my wex.nz dsh balance)* [eth] => *(my wex.nz eth balance)* [bch] => *(my wex.nz bch balance)* [usdet] => *(my wex.nz usdet balance)* [btcet] => *(my wex.nz btcet balance)* [ltcet] => *(my wex.nz ltcet balance)* [ethet] => *(my wex.nz ethet balance)* [nmcet] => *(my wex.nz nmcet balance)* [nvcet] => *(my wex.nz nvcet balance)* [ppcet] => *(my wex.nz ppcet balance)* [dshet] => *(my wex.nz dshet balance)* [ruret] => *(my wex.nz ruret balance)* [euret] => *(my wex.nz wuret balance)* [bchet] => *(my wex.nz bchetbalance)* [zec] => *(my wex.nz zec balance)* ) [rights] => Array ( [info] => 1 [trade] => 1 [withdraw] => 0 ) [transaction_count] => 0 [open_orders] => 1 [server_time] => 1508783902 )
and then: print_r($getInfo["return"]["funds"]), should give you Array ( ["usd"] ...
I tried but not success. It does not returned value of Array ( ["usd"].
Woala! I have it! Great! :)))))))))))))
can you please advice me now how to make and process when prices are up 10% to sell and when prices are down -10% or more to buy some of the currency ? :)
ALSO: Please tell me how to transfer now this returned value to parameter -> "$usdbalance" ?
Do you have any idea how to do that ? Many thanks!
Dear Tony,
Why you does not answer and closed my thread?