Advertisement
girinovey

Coleta Estatisticas da polo

Feb 23rd, 2018
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.67 KB | None | 0 0
  1. <?php
  2.  
  3. require_once "poloniex.php";
  4. // precisa alterar o poloniex.php fornecido pela polo
  5. // para que ele retorne "returnCompleteBalances" ao inves de "returnBalances"
  6.  
  7. $key = "SUA_API_KEY";
  8. $secret = "SEU_SECRET";
  9. $api = new poloniex($key, $secret);
  10. $dbfile="/var/www/anubis/db.sqlite3";
  11.  
  12. $balances = $api->get_balances();
  13. $btc_total = 0.0;
  14. foreach ($balances as $coin => $balance) {
  15.         $btc_total += $balance['btcValue'];
  16. }
  17.  
  18.  
  19. $db = new SQLite3($dbfile);
  20.  
  21. $stmt = $db->prepare("insert into balance values (:ts, :val)");
  22. $stmt->bindValue(':val', $btc_total, SQLITE3_FLOAT);
  23. $stmt->bindValue(':ts', time(), SQLITE3_INTEGER);
  24. $result = $stmt->execute();
  25.  
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement