Author

Topic: [PHP] Lib usada no centralbit (Read 4290 times)

hero member
Activity: 1078
Merit: 529
November 05, 2017, 01:34:38 PM
#19
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
hero member
Activity: 1078
Merit: 529
August 25, 2017, 08:42:48 AM
#18
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.

newbie
Activity: 4
Merit: 0
August 23, 2017, 09:40:40 PM
#17
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.
hero member
Activity: 1078
Merit: 529
August 23, 2017, 07:10:39 PM
#16
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.
newbie
Activity: 4
Merit: 0
August 23, 2017, 06:34:02 PM
#15
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);
hero member
Activity: 1078
Merit: 529
May 26, 2017, 06:54:19 PM
#14
koakoaokakoako

não não, estava afastado do bitcoin mesmo.


legendary
Activity: 2296
Merit: 1170
Advertise Here - PM for more info!
May 26, 2017, 05:52:03 PM
#13
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
hero member
Activity: 1078
Merit: 529
May 26, 2017, 01:10:24 PM
#12
Meio demorado mas como estou voltando agora, bora responder, kkk
isso mesmo foram utilizados apenas api públicas de consulta.


att

legendary
Activity: 2296
Merit: 1170
Advertise Here - PM for more info!
March 14, 2016, 06:28:22 PM
#11
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.
newbie
Activity: 28
Merit: 0
March 14, 2016, 01:42:56 PM
#10
Onde vai a minha api key no codigo?
hero member
Activity: 1078
Merit: 529
February 22, 2016, 07:54:51 PM
#9
Nova atualização da lib

Code:
//@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_mbiCURLOPT_RETURNTRANSFER1);
$json_q_mbi curl_exec($q_mbi);
curl_close($q_mbi);
$decode_q_mbi json_decode($json_q_mbitrue);
$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_b2uCURLOPT_RETURNTRANSFER1);
$json_q_b2u curl_exec($q_b2u);
curl_close($q_b2u);
$decode_q_b2u json_decode($json_q_b2utrue);
$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_foxCURLOPT_RETURNTRANSFER1);
$json_q_fox curl_exec($q_fox);
curl_close($q_fox);
$decode_q_fox json_decode($json_q_foxtrue);
$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_negCURLOPT_RETURNTRANSFER1);
$json_q_neg curl_exec($q_neg);
curl_close($q_neg);
$decode_q_neg json_decode($json_q_negtrue);
$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_fiatCURLOPT_RETURNTRANSFER1);
$json_q_fiat curl_exec($q_fiat);
curl_close($q_fiat);
$decode_q_fiat json_decode($json_q_fiattrue);
$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_btsCURLOPT_RETURNTRANSFER1);
$json_q_bts curl_exec($q_bts);
curl_close($q_bts);
$decode_q_bts json_decode($json_q_btstrue);
$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_btxCURLOPT_RETURNTRANSFER1);
$json_q_btx curl_exec($q_btx);
curl_close($q_btx);
$decode_q_btx json_decode($json_q_btxtrue);
$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_bpiCURLOPT_RETURNTRANSFER1);
$json_q_bpi curl_exec($q_bpi);
curl_close($q_bpi);
$decode_q_bpi json_decode($json_q_bpitrue);
$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_b2uCURLOPT_RETURNTRANSFER1);
$json_b_b2u curl_exec($b_b2u);
curl_close($b_b2u);
$decode_b_b2u json_decode($json_b_b2utrue);
$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_mbiCURLOPT_RETURNTRANSFER1);
$json_b_mbi curl_exec($b_mbi);
curl_close($b_mbi);
$decode_b_mbi json_decode($json_b_mbitrue);
$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_foxCURLOPT_RETURNTRANSFER1);
$json_b_fox curl_exec($b_fox);
curl_close($b_fox);
$decode_b_fox json_decode($json_b_foxtrue);
$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_negCURLOPT_RETURNTRANSFER1);
$json_b_neg curl_exec($b_neg);
curl_close($b_neg);
$decode_b_neg json_decode($json_b_negtrue);
$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'',''');
?>

hero member
Activity: 1078
Merit: 529
April 03, 2015, 08:05:42 AM
#8
@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

newbie
Activity: 44
Merit: 0
April 03, 2015, 01:11:21 AM
#7
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.
sr. member
Activity: 315
Merit: 250
April 02, 2015, 11:17:09 PM
#6
Algumas sugestoes...

1. Tire sua API Key do código que rapidamente vai ser bloqueada Smiley
2. Defina um timeout para seu script não ficar bloqueado quando uma exchange sair do ar:
Code:
curl_setopt($xxxxxx, CURLOPT_TIMEOUT, 5);

3. Se quiser usar HTTPS com a Basebit você vai precisar incluir isso:
Code:
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:
Code:
$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 Smiley
hero member
Activity: 1078
Merit: 529
April 02, 2015, 09:36:55 PM
#5
Opa, Exchange acho que o mercado já está meio saturado, meu negócio é reunir informações mesmo, rs


legendary
Activity: 1274
Merit: 1000
March 31, 2015, 12:21:33 AM
#4
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.
hero member
Activity: 1078
Merit: 529
March 30, 2015, 08:40:30 PM
#3
estamos ai Wink
legendary
Activity: 3304
Merit: 1617
★Bitvest.io★ Play Plinko or Invest!
March 29, 2015, 07:42:24 PM
#2
Legal você disponibilizar o script Arthur. Parabéns pelo trabalho
hero member
Activity: 1078
Merit: 529
March 29, 2015, 06:24:08 PM
#1
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

Code:
//@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_basCURLOPT_RETURNTRANSFER1);
$json_q_bas curl_exec($q_bas);
curl_close($q_bas);
$decode_q_bas json_decode($json_q_bastrue);
$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_mbiCURLOPT_RETURNTRANSFER1);
$json_q_mbi curl_exec($q_mbi);
curl_close($q_mbi);
$decode_q_mbi json_decode($json_q_mbitrue);
$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_b2uCURLOPT_RETURNTRANSFER1);
$json_q_b2u curl_exec($q_b2u);
curl_close($q_b2u);
$decode_q_b2u json_decode($json_q_b2utrue);
$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_bivCURLOPT_RETURNTRANSFER1);
$json_q_biv curl_exec($q_biv);
curl_close($q_biv);
$decode_q_biv json_decode($json_q_bivtrue);
$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_foxCURLOPT_RETURNTRANSFER1);
$json_q_fox curl_exec($q_fox);
curl_close($q_fox);
$decode_q_fox json_decode($json_q_foxtrue);
$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_fiatCURLOPT_RETURNTRANSFER1);
$json_q_fiat curl_exec($q_fiat);
curl_close($q_fiat);
$decode_q_fiat json_decode($json_q_fiattrue);
$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_btsCURLOPT_RETURNTRANSFER1);
$json_q_bts curl_exec($q_bts);
curl_close($q_bts);
$decode_q_bts json_decode($json_q_btstrue);
$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_btxCURLOPT_RETURNTRANSFER1);
$json_q_btx curl_exec($q_btx);
curl_close($q_btx);
$decode_q_btx json_decode($json_q_btxtrue);
$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_bpiCURLOPT_RETURNTRANSFER1);
$json_q_bpi curl_exec($q_bpi);
curl_close($q_bpi);
$decode_q_bpi json_decode($json_q_bpitrue);
$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_basCURLOPT_RETURNTRANSFER1);
$json_b_bas curl_exec($b_bas);
curl_close($b_bas);
$decode_b_bas json_decode($json_b_bastrue);
$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_b2uCURLOPT_RETURNTRANSFER1);
$json_b_b2u curl_exec($b_b2u);
curl_close($b_b2u);
$decode_b_b2u json_decode($json_b_b2utrue);
$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_mbiCURLOPT_RETURNTRANSFER1);
$json_b_mbi curl_exec($b_mbi);
curl_close($b_mbi);
$decode_b_mbi json_decode($json_b_mbitrue);
$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_bivCURLOPT_RETURNTRANSFER1);
$json_b_biv curl_exec($b_biv);
curl_close($b_biv);
$decode_b_biv json_decode($json_b_bivtrue);
$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_foxCURLOPT_RETURNTRANSFER1);
$json_b_fox curl_exec($b_fox);
curl_close($b_fox);
$decode_b_fox json_decode($json_b_foxtrue);
$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'',''');
?>

Jump to: