Blockchain ToBTC API not returning Php variable

0 votes

I am having trouble getting the Blockchain ToBTC API to return the value of a PHP variable.

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

$total_price+=$price;

$btc_total = echo "https://blockchain.info/tobtc?currency=USD&value=$total_price";

How can I make this happen?

Sep 20, 2018 in Blockchain by slayer
• 29,350 points
427 views

1 answer to this question.

0 votes

Seems like you have a syntax error in your code use this line to print url,

echo $btc_total = "https://blockchain.info/tobtc?currency=USD&value=$total_price";

You should use curl to get value from above url.

<?php
    $total_price += $price;
    $curl = curl_init('https://blockchain.info/tobtc?currency=USD&value='.$total_price);
    curl_setopt($curl, CURLOPT_FAILONERROR, true);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($curl);
    echo $result;
?>
answered Sep 20, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

Not able to send payments using Blockchain API.

Try the following code. It should help ...READ MORE

answered Jul 31, 2018 in Blockchain by slayer
• 29,350 points
444 views
+1 vote
1 answer

Transaction using Blockchain wallet APi

Each transaction requires a fee to be ...READ MORE

answered Jun 19, 2018 in Blockchain by Perry
• 17,100 points
471 views
+2 votes
1 answer

Blockchain declining my API key and I cannot understand why.

It's quite easy. Request the API key using ...READ MORE

answered Apr 3, 2018 in Blockchain by Christine
• 15,790 points
1,800 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
1,690 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,231 views
0 votes
1 answer

Not receiving any data from the BitStamp API.

I saw a code online that was ...READ MORE

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

Bitcoin: parsing Blockchain API using JSON

Because you only add one address to ...READ MORE

answered Aug 22, 2018 in Blockchain by digger
• 26,740 points
2,980 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP