bitcoin to currency converter and it s reverse in php

0 votes

I am using Bitcoin Currency Converter in PHP.So that I can convert Bitcoin to any currency (say USD) and Any Currency (say USD) to Bitcoins.

Is there any API to do it ?? Till now I am using this URL to convert any currency to Bitcoins https://blockchain.info/tobtc?currency=USD&value=83.652

but how to do it's reverse (convert from bitcoins to currency). Also, I don't know whether this result is correct or not.

Mar 29 in Blockchain by Soham
• 8,730 points
56 views

1 answer to this question.

0 votes

Ok, you can get the value by doing this:

//set currency
$currency = 'USD';
//get json response
$return = file_get_contents('http://data.mtgox.com/api/1/BTC'.$currency.'/ticker_fast');
//decode it (into an array rather than object [using 'true' parameter])
$info = json_decode($return, true);
//access the dollar value
$value = $info['return']['last_local']['value'];

It's a public API so you don't need to authenticate, you just get the contents of the page which is in JSON format and decode it into an array and access the value element.
You now know that 1 BTC = 90.20505 dollars - so therefore 1 dollar is equal to 0.0110858 Bitcoins. (1 / 90.20505).
You can do this with any currency.
Voila

answered Mar 31 by Rahul
• 8,980 points

Related Questions In Blockchain

0 votes
1 answer

bitcoin to currency converter and it's reverse in php

Ok, you can get the value by ...READ MORE

answered Apr 7 in Blockchain by Aditya
• 7,280 points
92 views
0 votes
1 answer

How to use bitcoin price as place holder in php?

You can do it by providing an ...READ MORE

answered Aug 21, 2018 in Blockchain by digger
• 26,720 points
255 views
0 votes
1 answer

How to create Bitcoin Address in PHP?

You need to understand that Bitcoin address and ...READ MORE

answered Aug 28, 2018 in Blockchain by Perry
• 17,100 points
3,758 views
+1 vote
1 answer
0 votes
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,440 points
627 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
972 views
0 votes
1 answer
0 votes
1 answer

How to set fee in raw bitcoin transaction using btcutil

To answer your question, the settxfee is ...READ MORE

answered Mar 24 in Blockchain by Rahul
• 8,980 points
69 views
0 votes
1 answer

how Localbitcoins and other bitcoin wallet able to send/receive without network fee

Organizations that offer online wallets aren't obligated ...READ MORE

answered Mar 31 in Blockchain by Rahul
• 8,980 points
22 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP