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,050 points
34 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
• 27,620 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,050 points
33 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,010 points
35 views
+1 vote
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
167 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
105 views
0 votes
1 answer
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
• 27,620 points
41 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
• 27,620 points
172 views