Title: [PHP] Lib usada no centralbit
Post by: arthurbonora on March 29, 2015, 10:24:08 PM
Fala pessoal, segue a lib usada no www.centralbit.com.br, nada mais é o que a extração das api´s das exchanges nacionais para arrays em PHP quem quiser usar fique a vontade att <?php //@AHGB /* ================================ Biblioteca PHP de Api´s das exchanges brasileiras usada na centralbit www.centralbit.com.br Elaborada por Arthur H G Bonora - www.bonora.com.br Blog: www.arthurbonora.com.br
=================================== */ // cotações //basebit $q_bas = curl_init('http://www.basebit.com.br/quote-BTC_BRL'); curl_setopt($q_bas, CURLOPT_RETURNTRANSFER, 1); $json_q_bas = curl_exec($q_bas); curl_close($q_bas); $decode_q_bas = json_decode($json_q_bas, true); $bas_last = number_format ($decode_q_bas[result][last],'2', ',', ''); $bas_hight = number_format ($decode_q_bas[result][high],'2', ',', ''); $bas_low = number_format ($decode_q_bas[result][low],'2', ',', ''); $bas_volume = number_format ($decode_q_bas[result][volume],'2', ',', ''); //mercado bitcoin $q_mbi = curl_init('https://www.mercadobitcoin.net/api/ticker/'); curl_setopt($q_mbi, CURLOPT_RETURNTRANSFER, 1); $json_q_mbi = curl_exec($q_mbi); curl_close($q_mbi); $decode_q_mbi = json_decode($json_q_mbi, true); $mbi_last = number_format ($decode_q_mbi[ticker][last],'2', ',', ''); $mbi_hight = number_format ($decode_q_mbi[ticker][high],'2', ',', ''); $mbi_low = number_format ($decode_q_mbi[ticker][low],'2', ',', ''); $mbi_buy = number_format ($decode_q_mbi[ticker][buy],'2', ',', ''); $mbi_sell = number_format ($decode_q_mbi[ticker][sell],'2', ',', ''); $mbi_volume = number_format ($decode_q_mbi[ticker][vol],'2', ',', ''); //bitcointoyou $q_b2u = curl_init('https://www.bitcointoyou.com/api/ticker.aspx'); curl_setopt($q_b2u, CURLOPT_RETURNTRANSFER, 1); $json_q_b2u = curl_exec($q_b2u); curl_close($q_b2u); $decode_q_b2u = json_decode($json_q_b2u, true); $b2u_last = number_format ($decode_q_b2u[ticker][last],'2', ',', ''); $b2u_hight = number_format ($decode_q_b2u[ticker][high],'2', ',', ''); $b2u_low = number_format ($decode_q_b2u[ticker][low],'2', ',', ''); $b2u_buy = number_format ($decode_q_b2u[ticker][buy],'2', ',', ''); $b2u_sell = number_format ($decode_q_b2u[ticker][sell],'2', ',', ''); $b2u_volume = number_format ($decode_q_b2u[ticker][vol],'2', ',', ''); //bitinvest $q_biv = curl_init('https://api.bitinvest.com.br/exchange/ticker?subscription-key=045303bd555f450096142fb1f8d822be'); curl_setopt($q_biv, CURLOPT_RETURNTRANSFER, 1); $json_q_biv = curl_exec($q_biv); curl_close($q_biv); $decode_q_biv = json_decode($json_q_biv, true); $biv_last = number_format ($decode_q_biv[last],'2', ',', ''); $biv_hight = number_format ($decode_q_biv[high],'2', ',', ''); $biv_low = number_format ($decode_q_biv[low],'2', ',', ''); $biv_volume = number_format ($decode_q_biv[volume],'2', ',', ''); //foxbit $q_fox = curl_init('https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC'); curl_setopt($q_fox, CURLOPT_RETURNTRANSFER, 1); $json_q_fox = curl_exec($q_fox); curl_close($q_fox); $decode_q_fox = json_decode($json_q_fox, true); $fox_last = number_format ($decode_q_fox[last],'2', ',', ''); $fox_hight = number_format ($decode_q_fox[high],'2', ',', ''); $fox_low = number_format ($decode_q_fox[low],'2', ',', ''); $fox_buy = number_format ($decode_q_fox[buy],'2', ',', ''); $fox_sell = number_format ($decode_q_fox[sell],'2', ',', ''); $fox_volume = number_format ($decode_q_fox[vol],'2', ',', ''); //fiat $q_fiat = curl_init('http://api.promasters.net.br/cotacao/v1/valores'); curl_setopt($q_fiat, CURLOPT_RETURNTRANSFER, 1); $json_q_fiat = curl_exec($q_fiat); curl_close($q_fiat); $decode_q_fiat = json_decode($json_q_fiat, true); $fiat_usd = number_format ($decode_q_fiat[valores][USD],'2', ',', ''); $fiat_eur = number_format ($decode_q_fiat[valores][EUR][valor],'2', ',', ''); //bitstamp $q_bts = curl_init('https://www.bitstamp.net/api/ticker/'); curl_setopt($q_bts, CURLOPT_RETURNTRANSFER, 1); $json_q_bts = curl_exec($q_bts); curl_close($q_bts); $decode_q_bts = json_decode($json_q_bts, true); $bts_last = number_format ($decode_q_bts[last],'2', ',', ''); $bts_hight = number_format ($decode_q_bts[high],'2', ',', ''); $bts_low = number_format ($decode_q_bts[low],'2', ',', ''); $bts_hight = number_format ($decode_q_bts[bid],'2', ',', ''); $bts_low = number_format ($decode_q_bts[ask],'2', ',', ''); $bts_volume = number_format ($decode_q_bts[volume],'2', ',', ''); //bitfinex $q_btx = curl_init('https://api.bitfinex.com/v1/pubticker/btcusd'); curl_setopt($q_btx, CURLOPT_RETURNTRANSFER, 1); $json_q_btx = curl_exec($q_btx); curl_close($q_btx); $decode_q_btx = json_decode($json_q_btx, true); $btx_last = number_format ($decode_q_btx[last_price],'2', ',', ''); $btx_hight = number_format ($decode_q_btx[high],'2', ',', ''); $btx_low = number_format ($decode_q_btx[low],'2', ',', ''); $btx_hight = number_format ($decode_q_btx[bid],'2', ',', ''); $btx_low = number_format ($decode_q_btx[ask],'2', ',', ''); $btx_volume = number_format ($decode_q_btx[volume],'2', ',', ''); //coindesk índice $q_bpi = curl_init('https://api.coindesk.com/v1/bpi/currentprice.json'); curl_setopt($q_bpi, CURLOPT_RETURNTRANSFER, 1); $json_q_bpi = curl_exec($q_bpi); curl_close($q_bpi); $decode_q_bpi = json_decode($json_q_bpi, true); $bpi_usd = number_format ($decode_q_bpi[bpi][USD][rate],'2', ',', ''); $bpi_gbp = number_format ($decode_q_bpi[bpi][GBP][rate],'2', ',', ''); $bpi_eur = number_format ($decode_q_bpi[bpi][EUR][rate],'2', ',', ''); // books //basebit $b_bas = curl_init('http://www.basebit.com.br/book-BTC_BRL'); curl_setopt($b_bas, CURLOPT_RETURNTRANSFER, 1); $json_b_bas = curl_exec($b_bas); curl_close($b_bas); $decode_b_bas = json_decode($json_b_bas, true); $bas_book_ask[0] = number_format ($decode_b_bas[result][asks][0][quantity],'5', ',', ''); $bas_book_ask[1] = number_format ($decode_b_bas[result][asks][0][price],'2', ',', ''); $bas_book_ask[2] = number_format ($decode_b_bas[result][asks][1][quantity],'5', ',', ''); $bas_book_ask[3] = number_format ($decode_b_bas[result][asks][1][price],'2', ',', ''); $bas_book_ask[4] = number_format ($decode_b_bas[result][asks][2][quantity],'5', ',', ''); $bas_book_ask[5] = number_format ($decode_b_bas[result][asks][2][price],'2', ',', ''); $bas_book_ask[6] = number_format ($decode_b_bas[result][asks][3][quantity],'5', ',', ''); $bas_book_ask[7] = number_format ($decode_b_bas[result][asks][3][price],'2', ',', ''); $bas_book_ask[8] = number_format ($decode_b_bas[result][asks][4][quantity],'5', ',', ''); $bas_book_ask[9] = number_format ($decode_b_bas[result][asks][4][price],'2', ',', ''); $bas_book_ask[10] = number_format ($decode_b_bas[result][asks][5][quantity],'5', ',', ''); $bas_book_ask[11] = number_format ($decode_b_bas[result][asks][5][price],'2', ',', ''); $bas_book_ask[12] = number_format ($decode_b_bas[result][asks][6][quantity],'5', ',', ''); $bas_book_ask[13] = number_format ($decode_b_bas[result][asks][6][price],'2', ',', ''); $bas_book_ask[14] = number_format ($decode_b_bas[result][asks][7][quantity],'5', ',', ''); $bas_book_ask[15] = number_format ($decode_b_bas[result][asks][7][price],'2', ',', ''); $bas_book_ask[16] = number_format ($decode_b_bas[result][asks][8][quantity],'5', ',', ''); $bas_book_ask[17] = number_format ($decode_b_bas[result][asks][8][price],'2', ',', ''); $bas_book_ask[18] = number_format ($decode_b_bas[result][asks][9][quantity],'5', ',', ''); $bas_book_ask[19] = number_format ($decode_b_bas[result][asks][9][price],'2', ',', ''); $bas_book_bid[0] = number_format ($decode_b_bas[result][bids][0][quantity],'5', ',', ''); $bas_book_bid[1] = number_format ($decode_b_bas[result][bids][0][price],'2', ',', ''); $bas_book_bid[2] = number_format ($decode_b_bas[result][bids][1][quantity],'5', ',', ''); $bas_book_bid[3] = number_format ($decode_b_bas[result][bids][1][price],'2', ',', ''); $bas_book_bid[4] = number_format ($decode_b_bas[result][bids][2][quantity],'5', ',', ''); $bas_book_bid[5] = number_format ($decode_b_bas[result][bids][2][price],'2', ',', ''); $bas_book_bid[6] = number_format ($decode_b_bas[result][bids][3][quantity],'5', ',', ''); $bas_book_bid[7] = number_format ($decode_b_bas[result][bids][3][price],'2', ',', ''); $bas_book_bid[8] = number_format ($decode_b_bas[result][bids][4][quantity],'5', ',', ''); $bas_book_bid[9] = number_format ($decode_b_bas[result][bids][4][price],'2', ',', ''); $bas_book_bid[10] = number_format ($decode_b_bas[result][bids][5][quantity],'5', ',', ''); $bas_book_bid[11] = number_format ($decode_b_bas[result][bids][5][price],'2', ',', ''); $bas_book_bid[12] = number_format ($decode_b_bas[result][bids][6][quantity],'5', ',', ''); $bas_book_bid[13] = number_format ($decode_b_bas[result][bids][6][price],'2', ',', ''); $bas_book_bid[14] = number_format ($decode_b_bas[result][bids][7][quantity],'5', ',', ''); $bas_book_bid[15] = number_format ($decode_b_bas[result][bids][7][price],'2', ',', ''); $bas_book_bid[16] = number_format ($decode_b_bas[result][bids][8][quantity],'5', ',', ''); $bas_book_bid[17] = number_format ($decode_b_bas[result][bids][8][price],'2', ',', ''); $bas_book_bid[18] = number_format ($decode_b_bas[result][bids][9][quantity],'5', ',', ''); $bas_book_bid[19] = number_format ($decode_b_bas[result][bids][9][price],'2', ',', '');
//bitcointoyou $b_b2u = curl_init('https://www.bitcointoyou.com/api/orderbook.aspx'); curl_setopt($b_b2u, CURLOPT_RETURNTRANSFER, 1); $json_b_b2u = curl_exec($b_b2u); curl_close($b_b2u); $decode_b_b2u = json_decode($json_b_b2u, true); $b2u_book_ask[0] = number_format ($decode_b_b2u[asks][0][1],'5', ',', ''); $b2u_book_ask[1] = number_format ($decode_b_b2u[asks][0][0],'2', ',', ''); $b2u_book_ask[2] = number_format ($decode_b_b2u[asks][1][1],'5', ',', ''); $b2u_book_ask[3] = number_format ($decode_b_b2u[asks][1][0],'2', ',', ''); $b2u_book_ask[4] = number_format ($decode_b_b2u[asks][2][1],'5', ',', ''); $b2u_book_ask[5] = number_format ($decode_b_b2u[asks][2][0],'2', ',', ''); $b2u_book_ask[6] = number_format ($decode_b_b2u[asks][3][1],'5', ',', ''); $b2u_book_ask[7] = number_format ($decode_b_b2u[asks][3][0],'2', ',', ''); $b2u_book_ask[8] = number_format ($decode_b_b2u[asks][4][1],'5', ',', ''); $b2u_book_ask[9] = number_format ($decode_b_b2u[asks][4][0],'2', ',', ''); $b2u_book_ask[10] = number_format ($decode_b_b2u[asks][5][1],'5', ',', ''); $b2u_book_ask[11] = number_format ($decode_b_b2u[asks][5][0],'2', ',', ''); $b2u_book_ask[12] = number_format ($decode_b_b2u[asks][6][1],'5', ',', ''); $b2u_book_ask[13] = number_format ($decode_b_b2u[asks][6][0],'2', ',', ''); $b2u_book_ask[14] = number_format ($decode_b_b2u[asks][7][1],'5', ',', ''); $b2u_book_ask[15] = number_format ($decode_b_b2u[asks][7][0],'2', ',', ''); $b2u_book_ask[16] = number_format ($decode_b_b2u[asks][8][1],'5', ',', ''); $b2u_book_ask[17] = number_format ($decode_b_b2u[asks][8][0],'2', ',', ''); $b2u_book_ask[18] = number_format ($decode_b_b2u[asks][9][1],'5', ',', ''); $b2u_book_ask[19] = number_format ($decode_b_b2u[asks][9][0],'2', ',', ''); $b2u_book_bid[0] = number_format ($decode_b_b2u[bids][0][1],'5', ',', ''); $b2u_book_bid[1] = number_format ($decode_b_b2u[bids][0][0],'2', ',', ''); $b2u_book_bid[2] = number_format ($decode_b_b2u[bids][1][1],'5', ',', ''); $b2u_book_bid[3] = number_format ($decode_b_b2u[bids][1][0],'2', ',', ''); $b2u_book_bid[4] = number_format ($decode_b_b2u[bids][2][1],'5', ',', ''); $b2u_book_bid[5] = number_format ($decode_b_b2u[bids][2][0],'2', ',', ''); $b2u_book_bid[6] = number_format ($decode_b_b2u[bids][3][1],'5', ',', ''); $b2u_book_bid[7] = number_format ($decode_b_b2u[bids][3][0],'2', ',', ''); $b2u_book_bid[8] = number_format ($decode_b_b2u[bids][4][1],'5', ',', ''); $b2u_book_bid[9] = number_format ($decode_b_b2u[bids][4][0],'2', ',', ''); $b2u_book_bid[10] = number_format ($decode_b_b2u[bids][5][1],'5', ',', ''); $b2u_book_bid[11] = number_format ($decode_b_b2u[bids][5][0],'2', ',', ''); $b2u_book_bid[12] = number_format ($decode_b_b2u[bids][6][1],'5', ',', ''); $b2u_book_bid[13] = number_format ($decode_b_b2u[bids][6][0],'2', ',', ''); $b2u_book_bid[14] = number_format ($decode_b_b2u[bids][7][1],'5', ',', ''); $b2u_book_bid[15] = number_format ($decode_b_b2u[bids][7][0],'2', ',', ''); $b2u_book_bid[16] = number_format ($decode_b_b2u[bids][8][1],'5', ',', ''); $b2u_book_bid[17] = number_format ($decode_b_b2u[bids][8][0],'2', ',', ''); $b2u_book_bid[18] = number_format ($decode_b_b2u[bids][9][1],'5', ',', ''); $b2u_book_bid[19] = number_format ($decode_b_b2u[bids][9][0],'2', ',', '');
//mercado bitcoin $b_mbi = curl_init('https://www.mercadobitcoin.net/api/orderbook/'); curl_setopt($b_mbi, CURLOPT_RETURNTRANSFER, 1); $json_b_mbi = curl_exec($b_mbi); curl_close($b_mbi); $decode_b_mbi = json_decode($json_b_mbi, true); $mbi_book_ask[0] = number_format ($decode_b_mbi[asks][0][1],'5', ',', ''); $mbi_book_ask[1] = number_format ($decode_b_mbi[asks][0][0],'2', ',', ''); $mbi_book_ask[2] = number_format ($decode_b_mbi[asks][1][1],'5', ',', ''); $mbi_book_ask[3] = number_format ($decode_b_mbi[asks][1][0],'2', ',', ''); $mbi_book_ask[4] = number_format ($decode_b_mbi[asks][2][1],'5', ',', ''); $mbi_book_ask[5] = number_format ($decode_b_mbi[asks][2][0],'2', ',', ''); $mbi_book_ask[6] = number_format ($decode_b_mbi[asks][3][1],'5', ',', ''); $mbi_book_ask[7] = number_format ($decode_b_mbi[asks][3][0],'2', ',', ''); $mbi_book_ask[8] = number_format ($decode_b_mbi[asks][4][1],'5', ',', ''); $mbi_book_ask[9] = number_format ($decode_b_mbi[asks][4][0],'2', ',', ''); $mbi_book_ask[10] = number_format ($decode_b_mbi[asks][5][1],'5', ',', ''); $mbi_book_ask[11] = number_format ($decode_b_mbi[asks][5][0],'2', ',', ''); $mbi_book_ask[12] = number_format ($decode_b_mbi[asks][6][1],'5', ',', ''); $mbi_book_ask[13] = number_format ($decode_b_mbi[asks][6][0],'2', ',', ''); $mbi_book_ask[14] = number_format ($decode_b_mbi[asks][7][1],'5', ',', ''); $mbi_book_ask[15] = number_format ($decode_b_mbi[asks][7][0],'2', ',', ''); $mbi_book_ask[16] = number_format ($decode_b_mbi[asks][8][1],'5', ',', ''); $mbi_book_ask[17] = number_format ($decode_b_mbi[asks][8][0],'2', ',', ''); $mbi_book_ask[18] = number_format ($decode_b_mbi[asks][9][1],'5', ',', ''); $mbi_book_ask[19] = number_format ($decode_b_mbi[asks][9][0],'2', ',', ''); $mbi_book_bid[0] = number_format ($decode_b_mbi[bids][0][1],'5', ',', ''); $mbi_book_bid[1] = number_format ($decode_b_mbi[bids][0][0],'2', ',', ''); $mbi_book_bid[2] = number_format ($decode_b_mbi[bids][1][1],'5', ',', ''); $mbi_book_bid[3] = number_format ($decode_b_mbi[bids][1][0],'2', ',', ''); $mbi_book_bid[4] = number_format ($decode_b_mbi[bids][2][1],'5', ',', ''); $mbi_book_bid[5] = number_format ($decode_b_mbi[bids][2][0],'2', ',', ''); $mbi_book_bid[6] = number_format ($decode_b_mbi[bids][3][1],'5', ',', ''); $mbi_book_bid[7] = number_format ($decode_b_mbi[bids][3][0],'2', ',', ''); $mbi_book_bid[8] = number_format ($decode_b_mbi[bids][4][1],'5', ',', ''); $mbi_book_bid[9] = number_format ($decode_b_mbi[bids][4][0],'2', ',', ''); $mbi_book_bid[10] = number_format ($decode_b_mbi[bids][5][1],'5', ',', ''); $mbi_book_bid[11] = number_format ($decode_b_mbi[bids][5][0],'2', ',', ''); $mbi_book_bid[12] = number_format ($decode_b_mbi[bids][6][1],'5', ',', ''); $mbi_book_bid[13] = number_format ($decode_b_mbi[bids][6][0],'2', ',', ''); $mbi_book_bid[14] = number_format ($decode_b_mbi[bids][7][1],'5', ',', ''); $mbi_book_bid[15] = number_format ($decode_b_mbi[bids][7][0],'2', ',', ''); $mbi_book_bid[16] = number_format ($decode_b_mbi[bids][8][1],'5', ',', ''); $mbi_book_bid[17] = number_format ($decode_b_mbi[bids][8][0],'2', ',', ''); $mbi_book_bid[18] = number_format ($decode_b_mbi[bids][9][1],'5', ',', ''); $mbi_book_bid[19] = number_format ($decode_b_mbi[bids][9][0],'2', ',', '');
//bitinvest $b_biv = curl_init('https://api.bitinvest.com.br/exchange/orderbook?subscription-key=045303bd555f450096142fb1f8d822be'); curl_setopt($b_biv, CURLOPT_RETURNTRANSFER, 1); $json_b_biv = curl_exec($b_biv); curl_close($b_biv); $decode_b_biv = json_decode($json_b_biv, true); $biv_book_ask[0] = number_format ($decode_b_biv[asks][0][1],'5', ',', ''); $biv_book_ask[1] = number_format ($decode_b_biv[asks][0][0],'2', ',', ''); $biv_book_ask[2] = number_format ($decode_b_biv[asks][1][1],'5', ',', ''); $biv_book_ask[3] = number_format ($decode_b_biv[asks][1][0],'2', ',', ''); $biv_book_ask[4] = number_format ($decode_b_biv[asks][2][1],'5', ',', ''); $biv_book_ask[5] = number_format ($decode_b_biv[asks][2][0],'2', ',', ''); $biv_book_ask[6] = number_format ($decode_b_biv[asks][3][1],'5', ',', ''); $biv_book_ask[7] = number_format ($decode_b_biv[asks][3][0],'2', ',', ''); $biv_book_ask[8] = number_format ($decode_b_biv[asks][4][1],'5', ',', ''); $biv_book_ask[9] = number_format ($decode_b_biv[asks][4][0],'2', ',', ''); $biv_book_ask[10] = number_format ($decode_b_biv[asks][5][1],'5', ',', ''); $biv_book_ask[11] = number_format ($decode_b_biv[asks][5][0],'2', ',', ''); $biv_book_ask[12] = number_format ($decode_b_biv[asks][6][1],'5', ',', ''); $biv_book_ask[13] = number_format ($decode_b_biv[asks][6][0],'2', ',', ''); $biv_book_ask[14] = number_format ($decode_b_biv[asks][7][1],'5', ',', ''); $biv_book_ask[15] = number_format ($decode_b_biv[asks][7][0],'2', ',', ''); $biv_book_ask[16] = number_format ($decode_b_biv[asks][8][1],'5', ',', ''); $biv_book_ask[17] = number_format ($decode_b_biv[asks][8][0],'2', ',', ''); $biv_book_ask[18] = number_format ($decode_b_biv[asks][9][1],'5', ',', ''); $biv_book_ask[19] = number_format ($decode_b_biv[asks][9][0],'2', ',', ''); $biv_book_bid[0] = number_format ($decode_b_biv[bids][0][1],'5', ',', ''); $biv_book_bid[1] = number_format ($decode_b_biv[bids][0][0],'2', ',', ''); $biv_book_bid[2] = number_format ($decode_b_biv[bids][1][1],'5', ',', ''); $biv_book_bid[3] = number_format ($decode_b_biv[bids][1][0],'2', ',', ''); $biv_book_bid[4] = number_format ($decode_b_biv[bids][2][1],'5', ',', ''); $biv_book_bid[5] = number_format ($decode_b_biv[bids][2][0],'2', ',', ''); $biv_book_bid[6] = number_format ($decode_b_biv[bids][3][1],'5', ',', ''); $biv_book_bid[7] = number_format ($decode_b_biv[bids][3][0],'2', ',', ''); $biv_book_bid[8] = number_format ($decode_b_biv[bids][4][1],'5', ',', ''); $biv_book_bid[9] = number_format ($decode_b_biv[bids][4][0],'2', ',', ''); $biv_book_bid[10] = number_format ($decode_b_biv[bids][5][1],'5', ',', ''); $biv_book_bid[11] = number_format ($decode_b_biv[bids][5][0],'2', ',', ''); $biv_book_bid[12] = number_format ($decode_b_biv[bids][6][1],'5', ',', ''); $biv_book_bid[13] = number_format ($decode_b_biv[bids][6][0],'2', ',', ''); $biv_book_bid[14] = number_format ($decode_b_biv[bids][7][1],'5', ',', ''); $biv_book_bid[15] = number_format ($decode_b_biv[bids][7][0],'2', ',', ''); $biv_book_bid[16] = number_format ($decode_b_biv[bids][8][1],'5', ',', ''); $biv_book_bid[17] = number_format ($decode_b_biv[bids][8][0],'2', ',', ''); $biv_book_bid[18] = number_format ($decode_b_biv[bids][9][1],'5', ',', ''); $biv_book_bid[19] = number_format ($decode_b_biv[bids][9][0],'2', ',', '');
//foxbit $b_fox = curl_init('https://api.blinktrade.com/api/v1/BRL/orderbook?crypto_currency=BTC'); curl_setopt($b_fox, CURLOPT_RETURNTRANSFER, 1); $json_b_fox = curl_exec($b_fox); curl_close($b_fox); $decode_b_fox = json_decode($json_b_fox, true); $fox_book_ask[0] = number_format ($decode_b_fox[asks][0][1],'5', ',', ''); $fox_book_ask[1] = number_format ($decode_b_fox[asks][0][0],'2', ',', ''); $fox_book_ask[2] = number_format ($decode_b_fox[asks][1][1],'5', ',', ''); $fox_book_ask[3] = number_format ($decode_b_fox[asks][1][0],'2', ',', ''); $fox_book_ask[4] = number_format ($decode_b_fox[asks][2][1],'5', ',', ''); $fox_book_ask[5] = number_format ($decode_b_fox[asks][2][0],'2', ',', ''); $fox_book_ask[6] = number_format ($decode_b_fox[asks][3][1],'5', ',', ''); $fox_book_ask[7] = number_format ($decode_b_fox[asks][3][0],'2', ',', ''); $fox_book_ask[8] = number_format ($decode_b_fox[asks][4][1],'5', ',', ''); $fox_book_ask[9] = number_format ($decode_b_fox[asks][4][0],'2', ',', ''); $fox_book_ask[10] = number_format ($decode_b_fox[asks][5][1],'5', ',', ''); $fox_book_ask[11] = number_format ($decode_b_fox[asks][5][0],'2', ',', ''); $fox_book_ask[12] = number_format ($decode_b_fox[asks][6][1],'5', ',', ''); $fox_book_ask[13] = number_format ($decode_b_fox[asks][6][0],'2', ',', ''); $fox_book_ask[14] = number_format ($decode_b_fox[asks][7][1],'5', ',', ''); $fox_book_ask[15] = number_format ($decode_b_fox[asks][7][0],'2', ',', ''); $fox_book_ask[16] = number_format ($decode_b_fox[asks][8][1],'5', ',', ''); $fox_book_ask[17] = number_format ($decode_b_fox[asks][8][0],'2', ',', ''); $fox_book_ask[18] = number_format ($decode_b_fox[asks][9][1],'5', ',', ''); $fox_book_ask[19] = number_format ($decode_b_fox[asks][9][0],'2', ',', ''); $fox_book_bid[0] = number_format ($decode_b_fox[bids][0][1],'5', ',', ''); $fox_book_bid[1] = number_format ($decode_b_fox[bids][0][0],'2', ',', ''); $fox_book_bid[2] = number_format ($decode_b_fox[bids][1][1],'5', ',', ''); $fox_book_bid[3] = number_format ($decode_b_fox[bids][1][0],'2', ',', ''); $fox_book_bid[4] = number_format ($decode_b_fox[bids][2][1],'5', ',', ''); $fox_book_bid[5] = number_format ($decode_b_fox[bids][2][0],'2', ',', ''); $fox_book_bid[6] = number_format ($decode_b_fox[bids][3][1],'5', ',', ''); $fox_book_bid[7] = number_format ($decode_b_fox[bids][3][0],'2', ',', ''); $fox_book_bid[8] = number_format ($decode_b_fox[bids][4][1],'5', ',', ''); $fox_book_bid[9] = number_format ($decode_b_fox[bids][4][0],'2', ',', ''); $fox_book_bid[10] = number_format ($decode_b_fox[bids][5][1],'5', ',', ''); $fox_book_bid[11] = number_format ($decode_b_fox[bids][5][0],'2', ',', ''); $fox_book_bid[12] = number_format ($decode_b_fox[bids][6][1],'5', ',', ''); $fox_book_bid[13] = number_format ($decode_b_fox[bids][6][0],'2', ',', ''); $fox_book_bid[14] = number_format ($decode_b_fox[bids][7][1],'5', ',', ''); $fox_book_bid[15] = number_format ($decode_b_fox[bids][7][0],'2', ',', ''); $fox_book_bid[16] = number_format ($decode_b_fox[bids][8][1],'5', ',', ''); $fox_book_bid[17] = number_format ($decode_b_fox[bids][8][0],'2', ',', ''); $fox_book_bid[18] = number_format ($decode_b_fox[bids][9][1],'5', ',', ''); $fox_book_bid[19] = number_format ($decode_b_fox[bids][9][0],'2', ',', ''); ?>
Title: Re: [PHP] Lib usada no centralbit
Post by: Paredao on March 29, 2015, 11:42:24 PM
Legal você disponibilizar o script Arthur. Parabéns pelo trabalho
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on March 31, 2015, 12:40:30 AM
estamos ai ;)
Title: Re: [PHP] Lib usada no centralbit
Post by: Googlulinks on March 31, 2015, 04:21:33 AM
Parabéns pelo trabalho Arthur. O negócio agora é você criar um programa para uma exchange própria. De preferência com uma boa segurança para evitar os Hackers que estão atacando algumas exchanges estrangeiras.
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on April 03, 2015, 01:36:55 AM
Opa, Exchange acho que o mercado já está meio saturado, meu negócio é reunir informações mesmo, rs
Title: Re: [PHP] Lib usada no centralbit
Post by: person on April 03, 2015, 03:17:09 AM
Algumas sugestoes... 1. Tire sua API Key do código que rapidamente vai ser bloqueada :) 2. Defina um timeout para seu script não ficar bloqueado quando uma exchange sair do ar: curl_setopt($xxxxxx, CURLOPT_TIMEOUT, 5);
3. Se quiser usar HTTPS com a Basebit você vai precisar incluir isso: curl_setopt($xxxxxx, CURLOPT_SSL_CIPHER_LIST, 'AES256-SHA:KRB5-DES-CBC3-MD5');
4. Não aplique o number_format na recuperação dos dados - apenas quando for exibir, ou seus cálculos podem complicar/sair errado/perder precisão. 5. Mude a recuperação dos dados do book para um loop com sizeof(matriz) ou o script vai quebrar toda vez que tiver um book curto. E também use uma "tupla" Qty/Preço ao inves de colocar cada item num elemento da matriz. Exemplo: $decode_b_bas = json_decode($json_b_bas, true); for ($i = 0; $i < sizeof($decode_b_bas[result][asks]); $i++) { $bas_book_ask[$i] = [number_format ($decode_b_bas[result][asks][$i][quantity],'5', ',', ''), number_format ($decode_b_bas[result][asks][$i][price],'2', ',', '')]; }
Isso vai reduzir umas 200 linhas do seu código :)
Title: Re: [PHP] Lib usada no centralbit
Post by: mj4y on April 03, 2015, 05:11:21 AM
Maravilha hein arthurbonora, sempre bom divulgar conhecimento, ia sugerir a mesma coisa que o person sugeriu no numero cinco, eu adoro api's estava com uma escrita em nodejs bombando no meu cubieboard2/archlinux infelizmente mandei um "rm -rf" alcool e brabo, mas este post e apenas para parabenizar a contribuição e sugerir uma linguagem dinâmica para quem quiser aproveitar a ideia, nodejs + angularjs ou o php + angularjs funciona muito bem para interface web.
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on April 03, 2015, 12:05:42 PM
@person - muito obrigado pelas sugestões, vou aplica-las
@mj4y - obrigado
O bacana de divulgar material é isso, podemos ter sugestões de melhorias, valew pessoal, depois posto atualizada
abs
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on February 22, 2016, 11:54:51 PM
Nova atualização da lib <?php //@AHGB /* ================================ Biblioteca PHP de Api´s das exchanges brasileiras usada na centralbit www.centralbit.com.br Elaborada por Arthur H G Bonora - www.bonora.com.br Blog: www.arthurbonora.com.br
=================================== */ // cotações //mercado bitcoin $q_mbi = curl_init('https://www.mercadobitcoin.net/api/ticker/'); curl_setopt($q_mbi, CURLOPT_RETURNTRANSFER, 1); $json_q_mbi = curl_exec($q_mbi); curl_close($q_mbi); $decode_q_mbi = json_decode($json_q_mbi, true); $mbi_last = number_format ($decode_q_mbi[ticker][last],'2', ',', ''); $mbi_hight = number_format ($decode_q_mbi[ticker][high],'2', ',', ''); $mbi_low = number_format ($decode_q_mbi[ticker][low],'2', ',', ''); $mbi_buy = number_format ($decode_q_mbi[ticker][buy],'2', ',', ''); $mbi_sell = number_format ($decode_q_mbi[ticker][sell],'2', ',', ''); $mbi_volume = number_format ($decode_q_mbi[ticker][vol],'2', ',', ''); //bitcointoyou $q_b2u = curl_init('https://www.bitcointoyou.com/api/ticker.aspx'); curl_setopt($q_b2u, CURLOPT_RETURNTRANSFER, 1); $json_q_b2u = curl_exec($q_b2u); curl_close($q_b2u); $decode_q_b2u = json_decode($json_q_b2u, true); $b2u_last = number_format ($decode_q_b2u[ticker][last],'2', ',', ''); $b2u_hight = number_format ($decode_q_b2u[ticker][high],'2', ',', ''); $b2u_low = number_format ($decode_q_b2u[ticker][low],'2', ',', ''); $b2u_buy = number_format ($decode_q_b2u[ticker][buy],'2', ',', ''); $b2u_sell = number_format ($decode_q_b2u[ticker][sell],'2', ',', ''); $b2u_volume = number_format ($decode_q_b2u[ticker][vol],'2', ',', ''); //foxbit $q_fox = curl_init('https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC'); curl_setopt($q_fox, CURLOPT_RETURNTRANSFER, 1); $json_q_fox = curl_exec($q_fox); curl_close($q_fox); $decode_q_fox = json_decode($json_q_fox, true); $fox_last = number_format ($decode_q_fox[last],'2', ',', ''); $fox_hight = number_format ($decode_q_fox[high],'2', ',', ''); $fox_low = number_format ($decode_q_fox[low],'2', ',', ''); $fox_buy = number_format ($decode_q_fox[buy],'2', ',', ''); $fox_sell = number_format ($decode_q_fox[sell],'2', ',', ''); $fox_volume = number_format ($decode_q_fox[vol],'2', ',', ''); //negociecoins $q_neg = curl_init('http://www.negociecoins.com.br/api/v3/btcbrl/ticker'); curl_setopt($q_neg, CURLOPT_RETURNTRANSFER, 1); $json_q_neg = curl_exec($q_neg); curl_close($q_neg); $decode_q_neg = json_decode($json_q_neg, true); $neg_last = number_format ($decode_q_neg[last],'2', ',', ''); $neg_hight = number_format ($decode_q_neg[high],'2', ',', ''); $neg_low = number_format ($decode_q_neg[low],'2', ',', ''); $neg_buy = number_format ($decode_q_neg[buy],'2', ',', ''); $neg_sell = number_format ($decode_q_neg[sell],'2', ',', ''); $neg_volume = number_format ($decode_q_neg[vol],'2', ',', ''); //fiat $q_fiat = curl_init('http://developers.agenciaideias.com.br/cotacoes/json'); curl_setopt($q_fiat, CURLOPT_RETURNTRANSFER, 1); $json_q_fiat = curl_exec($q_fiat); curl_close($q_fiat); $decode_q_fiat = json_decode($json_q_fiat, true); $fiat_usd = $decode_q_fiat[dolar][cotacao]; $fiat_eur = $decode_q_fiat[euro][cotacao]; //bitstamp $q_bts = curl_init('https://www.bitstamp.net/api/ticker/'); curl_setopt($q_bts, CURLOPT_RETURNTRANSFER, 1); $json_q_bts = curl_exec($q_bts); curl_close($q_bts); $decode_q_bts = json_decode($json_q_bts, true); $bts_last = number_format ($decode_q_bts[last],'2', ',', ''); $bts_hight = number_format ($decode_q_bts[high],'2', ',', ''); $bts_low = number_format ($decode_q_bts[low],'2', ',', ''); $bts_hight = number_format ($decode_q_bts[bid],'2', ',', ''); $bts_low = number_format ($decode_q_bts[ask],'2', ',', ''); $bts_volume = number_format ($decode_q_bts[volume],'2', ',', ''); //bitfinex $q_btx = curl_init('https://api.bitfinex.com/v1/pubticker/btcusd'); curl_setopt($q_btx, CURLOPT_RETURNTRANSFER, 1); $json_q_btx = curl_exec($q_btx); curl_close($q_btx); $decode_q_btx = json_decode($json_q_btx, true); $btx_last = number_format ($decode_q_btx[last_price],'2', ',', ''); $btx_hight = number_format ($decode_q_btx[high],'2', ',', ''); $btx_low = number_format ($decode_q_btx[low],'2', ',', ''); $btx_hight = number_format ($decode_q_btx[bid],'2', ',', ''); $btx_low = number_format ($decode_q_btx[ask],'2', ',', ''); $btx_volume = number_format ($decode_q_btx[volume],'2', ',', ''); //coindesk índice $q_bpi = curl_init('https://api.coindesk.com/v1/bpi/currentprice.json'); curl_setopt($q_bpi, CURLOPT_RETURNTRANSFER, 1); $json_q_bpi = curl_exec($q_bpi); curl_close($q_bpi); $decode_q_bpi = json_decode($json_q_bpi, true); $bpi_usd = number_format ($decode_q_bpi[bpi][USD][rate],'2', ',', ''); $bpi_gbp = number_format ($decode_q_bpi[bpi][GBP][rate],'2', ',', ''); $bpi_eur = number_format ($decode_q_bpi[bpi][EUR][rate],'2', ',', ''); // books //bitcointoyou $b_b2u = curl_init('https://www.bitcointoyou.com/api/orderbook.aspx'); curl_setopt($b_b2u, CURLOPT_RETURNTRANSFER, 1); $json_b_b2u = curl_exec($b_b2u); curl_close($b_b2u); $decode_b_b2u = json_decode($json_b_b2u, true); $b2u_book_ask[0] = number_format ($decode_b_b2u[asks][0][1],'5', ',', ''); $b2u_book_ask[1] = number_format ($decode_b_b2u[asks][0][0],'2', ',', ''); $b2u_book_ask[2] = number_format ($decode_b_b2u[asks][1][1],'5', ',', ''); $b2u_book_ask[3] = number_format ($decode_b_b2u[asks][1][0],'2', ',', ''); $b2u_book_ask[4] = number_format ($decode_b_b2u[asks][2][1],'5', ',', ''); $b2u_book_ask[5] = number_format ($decode_b_b2u[asks][2][0],'2', ',', ''); $b2u_book_ask[6] = number_format ($decode_b_b2u[asks][3][1],'5', ',', ''); $b2u_book_ask[7] = number_format ($decode_b_b2u[asks][3][0],'2', ',', ''); $b2u_book_ask[8] = number_format ($decode_b_b2u[asks][4][1],'5', ',', ''); $b2u_book_ask[9] = number_format ($decode_b_b2u[asks][4][0],'2', ',', ''); $b2u_book_ask[10] = number_format ($decode_b_b2u[asks][5][1],'5', ',', ''); $b2u_book_ask[11] = number_format ($decode_b_b2u[asks][5][0],'2', ',', ''); $b2u_book_ask[12] = number_format ($decode_b_b2u[asks][6][1],'5', ',', ''); $b2u_book_ask[13] = number_format ($decode_b_b2u[asks][6][0],'2', ',', ''); $b2u_book_ask[14] = number_format ($decode_b_b2u[asks][7][1],'5', ',', ''); $b2u_book_ask[15] = number_format ($decode_b_b2u[asks][7][0],'2', ',', ''); $b2u_book_ask[16] = number_format ($decode_b_b2u[asks][8][1],'5', ',', ''); $b2u_book_ask[17] = number_format ($decode_b_b2u[asks][8][0],'2', ',', ''); $b2u_book_ask[18] = number_format ($decode_b_b2u[asks][9][1],'5', ',', ''); $b2u_book_ask[19] = number_format ($decode_b_b2u[asks][9][0],'2', ',', ''); $b2u_book_bid[0] = number_format ($decode_b_b2u[bids][0][1],'5', ',', ''); $b2u_book_bid[1] = number_format ($decode_b_b2u[bids][0][0],'2', ',', ''); $b2u_book_bid[2] = number_format ($decode_b_b2u[bids][1][1],'5', ',', ''); $b2u_book_bid[3] = number_format ($decode_b_b2u[bids][1][0],'2', ',', ''); $b2u_book_bid[4] = number_format ($decode_b_b2u[bids][2][1],'5', ',', ''); $b2u_book_bid[5] = number_format ($decode_b_b2u[bids][2][0],'2', ',', ''); $b2u_book_bid[6] = number_format ($decode_b_b2u[bids][3][1],'5', ',', ''); $b2u_book_bid[7] = number_format ($decode_b_b2u[bids][3][0],'2', ',', ''); $b2u_book_bid[8] = number_format ($decode_b_b2u[bids][4][1],'5', ',', ''); $b2u_book_bid[9] = number_format ($decode_b_b2u[bids][4][0],'2', ',', ''); $b2u_book_bid[10] = number_format ($decode_b_b2u[bids][5][1],'5', ',', ''); $b2u_book_bid[11] = number_format ($decode_b_b2u[bids][5][0],'2', ',', ''); $b2u_book_bid[12] = number_format ($decode_b_b2u[bids][6][1],'5', ',', ''); $b2u_book_bid[13] = number_format ($decode_b_b2u[bids][6][0],'2', ',', ''); $b2u_book_bid[14] = number_format ($decode_b_b2u[bids][7][1],'5', ',', ''); $b2u_book_bid[15] = number_format ($decode_b_b2u[bids][7][0],'2', ',', ''); $b2u_book_bid[16] = number_format ($decode_b_b2u[bids][8][1],'5', ',', ''); $b2u_book_bid[17] = number_format ($decode_b_b2u[bids][8][0],'2', ',', ''); $b2u_book_bid[18] = number_format ($decode_b_b2u[bids][9][1],'5', ',', ''); $b2u_book_bid[19] = number_format ($decode_b_b2u[bids][9][0],'2', ',', ''); //mercado bitcoin $b_mbi = curl_init('https://www.mercadobitcoin.net/api/orderbook/'); curl_setopt($b_mbi, CURLOPT_RETURNTRANSFER, 1); $json_b_mbi = curl_exec($b_mbi); curl_close($b_mbi); $decode_b_mbi = json_decode($json_b_mbi, true); $mbi_book_ask[0] = number_format ($decode_b_mbi[asks][0][1],'5', ',', ''); $mbi_book_ask[1] = number_format ($decode_b_mbi[asks][0][0],'2', ',', ''); $mbi_book_ask[2] = number_format ($decode_b_mbi[asks][1][1],'5', ',', ''); $mbi_book_ask[3] = number_format ($decode_b_mbi[asks][1][0],'2', ',', ''); $mbi_book_ask[4] = number_format ($decode_b_mbi[asks][2][1],'5', ',', ''); $mbi_book_ask[5] = number_format ($decode_b_mbi[asks][2][0],'2', ',', ''); $mbi_book_ask[6] = number_format ($decode_b_mbi[asks][3][1],'5', ',', ''); $mbi_book_ask[7] = number_format ($decode_b_mbi[asks][3][0],'2', ',', ''); $mbi_book_ask[8] = number_format ($decode_b_mbi[asks][4][1],'5', ',', ''); $mbi_book_ask[9] = number_format ($decode_b_mbi[asks][4][0],'2', ',', ''); $mbi_book_ask[10] = number_format ($decode_b_mbi[asks][5][1],'5', ',', ''); $mbi_book_ask[11] = number_format ($decode_b_mbi[asks][5][0],'2', ',', ''); $mbi_book_ask[12] = number_format ($decode_b_mbi[asks][6][1],'5', ',', ''); $mbi_book_ask[13] = number_format ($decode_b_mbi[asks][6][0],'2', ',', ''); $mbi_book_ask[14] = number_format ($decode_b_mbi[asks][7][1],'5', ',', ''); $mbi_book_ask[15] = number_format ($decode_b_mbi[asks][7][0],'2', ',', ''); $mbi_book_ask[16] = number_format ($decode_b_mbi[asks][8][1],'5', ',', ''); $mbi_book_ask[17] = number_format ($decode_b_mbi[asks][8][0],'2', ',', ''); $mbi_book_ask[18] = number_format ($decode_b_mbi[asks][9][1],'5', ',', ''); $mbi_book_ask[19] = number_format ($decode_b_mbi[asks][9][0],'2', ',', ''); $mbi_book_bid[0] = number_format ($decode_b_mbi[bids][0][1],'5', ',', ''); $mbi_book_bid[1] = number_format ($decode_b_mbi[bids][0][0],'2', ',', ''); $mbi_book_bid[2] = number_format ($decode_b_mbi[bids][1][1],'5', ',', ''); $mbi_book_bid[3] = number_format ($decode_b_mbi[bids][1][0],'2', ',', ''); $mbi_book_bid[4] = number_format ($decode_b_mbi[bids][2][1],'5', ',', ''); $mbi_book_bid[5] = number_format ($decode_b_mbi[bids][2][0],'2', ',', ''); $mbi_book_bid[6] = number_format ($decode_b_mbi[bids][3][1],'5', ',', ''); $mbi_book_bid[7] = number_format ($decode_b_mbi[bids][3][0],'2', ',', ''); $mbi_book_bid[8] = number_format ($decode_b_mbi[bids][4][1],'5', ',', ''); $mbi_book_bid[9] = number_format ($decode_b_mbi[bids][4][0],'2', ',', ''); $mbi_book_bid[10] = number_format ($decode_b_mbi[bids][5][1],'5', ',', ''); $mbi_book_bid[11] = number_format ($decode_b_mbi[bids][5][0],'2', ',', ''); $mbi_book_bid[12] = number_format ($decode_b_mbi[bids][6][1],'5', ',', ''); $mbi_book_bid[13] = number_format ($decode_b_mbi[bids][6][0],'2', ',', ''); $mbi_book_bid[14] = number_format ($decode_b_mbi[bids][7][1],'5', ',', ''); $mbi_book_bid[15] = number_format ($decode_b_mbi[bids][7][0],'2', ',', ''); $mbi_book_bid[16] = number_format ($decode_b_mbi[bids][8][1],'5', ',', ''); $mbi_book_bid[17] = number_format ($decode_b_mbi[bids][8][0],'2', ',', ''); $mbi_book_bid[18] = number_format ($decode_b_mbi[bids][9][1],'5', ',', ''); $mbi_book_bid[19] = number_format ($decode_b_mbi[bids][9][0],'2', ',', ''); //foxbit $b_fox = curl_init('https://api.blinktrade.com/api/v1/BRL/orderbook?crypto_currency=BTC'); curl_setopt($b_fox, CURLOPT_RETURNTRANSFER, 1); $json_b_fox = curl_exec($b_fox); curl_close($b_fox); $decode_b_fox = json_decode($json_b_fox, true); $fox_book_ask[0] = number_format ($decode_b_fox[asks][0][1],'5', ',', ''); $fox_book_ask[1] = number_format ($decode_b_fox[asks][0][0],'2', ',', ''); $fox_book_ask[2] = number_format ($decode_b_fox[asks][1][1],'5', ',', ''); $fox_book_ask[3] = number_format ($decode_b_fox[asks][1][0],'2', ',', ''); $fox_book_ask[4] = number_format ($decode_b_fox[asks][2][1],'5', ',', ''); $fox_book_ask[5] = number_format ($decode_b_fox[asks][2][0],'2', ',', ''); $fox_book_ask[6] = number_format ($decode_b_fox[asks][3][1],'5', ',', ''); $fox_book_ask[7] = number_format ($decode_b_fox[asks][3][0],'2', ',', ''); $fox_book_ask[8] = number_format ($decode_b_fox[asks][4][1],'5', ',', ''); $fox_book_ask[9] = number_format ($decode_b_fox[asks][4][0],'2', ',', ''); $fox_book_ask[10] = number_format ($decode_b_fox[asks][5][1],'5', ',', ''); $fox_book_ask[11] = number_format ($decode_b_fox[asks][5][0],'2', ',', ''); $fox_book_ask[12] = number_format ($decode_b_fox[asks][6][1],'5', ',', ''); $fox_book_ask[13] = number_format ($decode_b_fox[asks][6][0],'2', ',', ''); $fox_book_ask[14] = number_format ($decode_b_fox[asks][7][1],'5', ',', ''); $fox_book_ask[15] = number_format ($decode_b_fox[asks][7][0],'2', ',', ''); $fox_book_ask[16] = number_format ($decode_b_fox[asks][8][1],'5', ',', ''); $fox_book_ask[17] = number_format ($decode_b_fox[asks][8][0],'2', ',', ''); $fox_book_ask[18] = number_format ($decode_b_fox[asks][9][1],'5', ',', ''); $fox_book_ask[19] = number_format ($decode_b_fox[asks][9][0],'2', ',', ''); $fox_book_bid[0] = number_format ($decode_b_fox[bids][0][1],'5', ',', ''); $fox_book_bid[1] = number_format ($decode_b_fox[bids][0][0],'2', ',', ''); $fox_book_bid[2] = number_format ($decode_b_fox[bids][1][1],'5', ',', ''); $fox_book_bid[3] = number_format ($decode_b_fox[bids][1][0],'2', ',', ''); $fox_book_bid[4] = number_format ($decode_b_fox[bids][2][1],'5', ',', ''); $fox_book_bid[5] = number_format ($decode_b_fox[bids][2][0],'2', ',', ''); $fox_book_bid[6] = number_format ($decode_b_fox[bids][3][1],'5', ',', ''); $fox_book_bid[7] = number_format ($decode_b_fox[bids][3][0],'2', ',', ''); $fox_book_bid[8] = number_format ($decode_b_fox[bids][4][1],'5', ',', ''); $fox_book_bid[9] = number_format ($decode_b_fox[bids][4][0],'2', ',', ''); $fox_book_bid[10] = number_format ($decode_b_fox[bids][5][1],'5', ',', ''); $fox_book_bid[11] = number_format ($decode_b_fox[bids][5][0],'2', ',', ''); $fox_book_bid[12] = number_format ($decode_b_fox[bids][6][1],'5', ',', ''); $fox_book_bid[13] = number_format ($decode_b_fox[bids][6][0],'2', ',', ''); $fox_book_bid[14] = number_format ($decode_b_fox[bids][7][1],'5', ',', ''); $fox_book_bid[15] = number_format ($decode_b_fox[bids][7][0],'2', ',', ''); $fox_book_bid[16] = number_format ($decode_b_fox[bids][8][1],'5', ',', ''); $fox_book_bid[17] = number_format ($decode_b_fox[bids][8][0],'2', ',', ''); $fox_book_bid[18] = number_format ($decode_b_fox[bids][9][1],'5', ',', ''); $fox_book_bid[19] = number_format ($decode_b_fox[bids][9][0],'2', ',', ''); //negocie coins $b_neg = curl_init('http://www.negociecoins.com.br/api/v3/btcbrl/orderbook'); curl_setopt($b_neg, CURLOPT_RETURNTRANSFER, 1); $json_b_neg = curl_exec($b_neg); curl_close($b_neg); $decode_b_neg = json_decode($json_b_neg, true); $neg_book_ask[0] = number_format ($decode_b_neg[asks][0][1],'5', ',', ''); $neg_book_ask[1] = number_format ($decode_b_neg[asks][0][0],'2', ',', ''); $neg_book_ask[2] = number_format ($decode_b_neg[asks][1][1],'5', ',', ''); $neg_book_ask[3] = number_format ($decode_b_neg[asks][1][0],'2', ',', ''); $neg_book_ask[4] = number_format ($decode_b_neg[asks][2][1],'5', ',', ''); $neg_book_ask[5] = number_format ($decode_b_neg[asks][2][0],'2', ',', ''); $neg_book_ask[6] = number_format ($decode_b_neg[asks][3][1],'5', ',', ''); $neg_book_ask[7] = number_format ($decode_b_neg[asks][3][0],'2', ',', ''); $neg_book_ask[8] = number_format ($decode_b_neg[asks][4][1],'5', ',', ''); $neg_book_ask[9] = number_format ($decode_b_neg[asks][4][0],'2', ',', ''); $neg_book_ask[10] = number_format ($decode_b_neg[asks][5][1],'5', ',', ''); $neg_book_ask[11] = number_format ($decode_b_neg[asks][5][0],'2', ',', ''); $neg_book_ask[12] = number_format ($decode_b_neg[asks][6][1],'5', ',', ''); $neg_book_ask[13] = number_format ($decode_b_neg[asks][6][0],'2', ',', ''); $neg_book_ask[14] = number_format ($decode_b_neg[asks][7][1],'5', ',', ''); $neg_book_ask[15] = number_format ($decode_b_neg[asks][7][0],'2', ',', ''); $neg_book_ask[16] = number_format ($decode_b_neg[asks][8][1],'5', ',', ''); $neg_book_ask[17] = number_format ($decode_b_neg[asks][8][0],'2', ',', ''); $neg_book_ask[18] = number_format ($decode_b_neg[asks][9][1],'5', ',', ''); $neg_book_ask[19] = number_format ($decode_b_neg[asks][9][0],'2', ',', ''); $neg_book_bid[0] = number_format ($decode_b_neg[bids][0][1],'5', ',', ''); $neg_book_bid[1] = number_format ($decode_b_neg[bids][0][0],'2', ',', ''); $neg_book_bid[2] = number_format ($decode_b_neg[bids][1][1],'5', ',', ''); $neg_book_bid[3] = number_format ($decode_b_neg[bids][1][0],'2', ',', ''); $neg_book_bid[4] = number_format ($decode_b_neg[bids][2][1],'5', ',', ''); $neg_book_bid[5] = number_format ($decode_b_neg[bids][2][0],'2', ',', ''); $neg_book_bid[6] = number_format ($decode_b_neg[bids][3][1],'5', ',', ''); $neg_book_bid[7] = number_format ($decode_b_neg[bids][3][0],'2', ',', ''); $neg_book_bid[8] = number_format ($decode_b_neg[bids][4][1],'5', ',', ''); $neg_book_bid[9] = number_format ($decode_b_neg[bids][4][0],'2', ',', ''); $neg_book_bid[10] = number_format ($decode_b_neg[bids][5][1],'5', ',', ''); $neg_book_bid[11] = number_format ($decode_b_neg[bids][5][0],'2', ',', ''); $neg_book_bid[12] = number_format ($decode_b_neg[bids][6][1],'5', ',', ''); $neg_book_bid[13] = number_format ($decode_b_neg[bids][6][0],'2', ',', ''); $neg_book_bid[14] = number_format ($decode_b_neg[bids][7][1],'5', ',', ''); $neg_book_bid[15] = number_format ($decode_b_neg[bids][7][0],'2', ',', ''); $neg_book_bid[16] = number_format ($decode_b_neg[bids][8][1],'5', ',', ''); $neg_book_bid[17] = number_format ($decode_b_neg[bids][8][0],'2', ',', ''); $neg_book_bid[18] = number_format ($decode_b_neg[bids][9][1],'5', ',', ''); $neg_book_bid[19] = number_format ($decode_b_neg[bids][9][0],'2', ',', ''); ?>
Title: Re: [PHP] Lib usada no centralbit
Post by: ramonsz on March 14, 2016, 05:42:56 PM
Onde vai a minha api key no codigo?
Title: Re: [PHP] Lib usada no centralbit
Post by: girino on March 14, 2016, 10:28:22 PM
Onde vai a minha api key no codigo?
ach oque em nenhum lugar, pelo que vi do codigo ele usa as apis publicas e não as apis autenticadas.
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on May 26, 2017, 05:10:24 PM
Meio demorado mas como estou voltando agora, bora responder, kkk isso mesmo foram utilizados apenas api públicas de consulta.
att
Title: Re: [PHP] Lib usada no centralbit
Post by: girino on May 26, 2017, 09:52:03 PM
Meio demorado mas como estou voltando agora, bora responder, kkk isso mesmo foram utilizados apenas api públicas de consulta.
att
1 ano de demora na resposta? tá trabalhando no governo por acaso? :-D
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on May 26, 2017, 10:54:19 PM
koakoaokakoako
não não, estava afastado do bitcoin mesmo.
Title: Re: [PHP] Lib usada no centralbit
Post by: mboczko on August 23, 2017, 10:34:02 PM
Olá, pessoal.
eu estava atualizando meu código API para negociecoins.com.br mas precisei de suporte e eles estão demorando demais para dar suporte. As solicitações GET funcionam perfeito, mas as solicitações POST eu não sei como enviar. Tenho o seguinte código para POST (na tentativa de para criar ordem "buy"). Se alguém souber como enviar a API key e os parâmetros de POST eu agradeço.
//POST method $negocieCoinsApiKey = "XXX...."; //your api key $negocieCoinsApiUser = "YYY...."; $negocieUrl = "https://broker.negociecoins.com.br/tradeapi/v1/user/order/"; $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $negocieUrl); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(array( "brokerID" => 1, "userID" => $userId, "pair" => "BRLBTC", "type" => "buy", "volume" => 0.1, "price" => 13000 )));
$jsonReturn = curl_exec($ch);
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on August 23, 2017, 11:10:39 PM
eu não conheço bem a API da negocie, mas verifique qual a forma de autenticação, eu acredito que para negociações você precisa fazer um basic authentication, se for este caso passe como header na sua chamada.
Title: Re: [PHP] Lib usada no centralbit
Post by: mboczko on August 24, 2017, 01:40:40 AM
OK, obrigado pela ajuda, mas sou beginner, não entendo a nomenclatura de API (não sei o que é o header da chamada nem como passar o header). eu precisaria de exemplo do código. Sobre a documentação que consta no site da negociecoins, segue:
https://www.negociecoins.com.br/documentacao-tradeapi.aspx
O cabeçalho de autorização AMX é usado para proteger o acesso à nossa API de TRADE. Ele usa um token por chamada que é gerado usando o ID da API e a chave (API KEY) que foram fornecidos a você. Ele criptografa o conteúdo e usa um NONCE como segurança adicional.
Criar ordem de compra: Formato da Requisição: POST URL para Requisição: https://broker.negociecoins.com.br/tradeapi/v1/user/order
brokerID = Inteiro: Id único da exchange onde a ordem será criada. Usar 1 para a NegocieCoins. userID = Inteiro: Id único do usuário. pair = String: Define o filtro por par de moedas das ordens de negociação. Usar "BRLBTC"ou "BRLLTC". type = String: Define o filtro por tipo de operação das ordens de negociação. Usar "buy" ou "sell". volume = Decimal: Define a quantidade de criptmoedas a ser executada nesta ordem. price = Decimal: Define o preço da ordem de negociação a ser executada.
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on August 25, 2017, 12:42:48 PM
ixi, mas passar código pronto é tenso eim, pesquisa por basic authentication no googlão. header será mais uma opção de post dentro da curl sua.
Title: Re: [PHP] Lib usada no centralbit
Post by: arthurbonora on November 05, 2017, 05:34:38 PM
Pessoal, estou resgatando o tópico para informar que estou resgatando também o sistema centralbit, e em breve promoverei as atualizações... o novo endereço é http://www.centralbit.bonora.com.br (http://www.centralbit.bonora.com.br)
|