Skip to main contentSkip to footer

USD to bitcoin, bitcoin exchange rate - Php code

Rupak Nepali
Share:
USD to bitcoin, bitcoin exchange rate - Php code

Convert USD to bitcoin or get the latest value of bitcoin. The easiest way to get the bitcoin exchange rate

<?php
$amount=100;
$curl = curl_init();
curl_setopt_array($curl, array(
    CURLOPT_URL => "https://blockchain.info/tobtc?currency=USD&value=" . $amount,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
        "cache-control: no-cache",
        "postman-token: fc62ebce-6d0b-ef4f-ba02-fcb05e284a02"
    ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
echo $amount = json_decode($response);
?>

Above is programmatic code that you can use in your server but if you want to see in the browser then just do

https://blockchain.info/tobtc?currency=USD&value=100

Parameters
  • currency – A currency code. See the list above.
  • value – Value to convert.

Returns the value in BTC.

Comments

Join the conversation and share your thoughts

Leave a Comment

Your comment will be reviewed before publishing.

Be the first to comment on this post!

Innovation

Let's Make Something Amazing Together

We always provide our best creative ideas at the highest level. Tell us about your project and we will make it work.

InnovateBringing innovative solutions to complex problems
AutomateStreamlining processes through automation
DominateLeading the market with exceptional results
Build Smarter and Launch FasterEfficient development for rapid deployment