Bitcoin Forum
May 09, 2024, 05:46:16 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BTC to USD (or similar currency)  (Read 906 times)
sandaq (OP)
Member
**
Offline Offline

Activity: 72
Merit: 11


View Profile WWW
August 25, 2016, 05:58:29 AM
 #1

I'm looking for a php (or javascript) function to replace BTC to USD just like the one google uses https://www.google.co.il/search?q=btc+to+usd&ie=utf-8&oe=utf-8&client=firefox-b&gfe_rd=cr&ei=IIi-V-LaPMyN8QeGkI_YBQ

This should be something that prints the USD price automatically when you enter the BTC or vice versa, not something that you have to press submit and then it gets the price for you, this I already have:

Code:
$url = "https://api.bitcoinaverage.com/ticker/ILS/";
$json = json_decode(file_get_contents($url), true);
$price = $json["last"];

It needs to be automatically. There's no need for all the currencies. Just btc to usd (I will change the currency later) that will be shown automatically.

1715233576
Hero Member
*
Offline Offline

Posts: 1715233576

View Profile Personal Message (Offline)

Ignore
1715233576
Reply with quote  #2

1715233576
Report to moderator
TalkImg was created especially for hosting images on bitcointalk.org: try it next time you want to post an image
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715233576
Hero Member
*
Offline Offline

Posts: 1715233576

View Profile Personal Message (Offline)

Ignore
1715233576
Reply with quote  #2

1715233576
Report to moderator
sandaq (OP)
Member
**
Offline Offline

Activity: 72
Merit: 11


View Profile WWW
August 25, 2016, 11:35:28 AM
 #2

To whoever is interested I found out how to do it. It's still a bit crude but works:

Code:
<?

$margin=1.05;
$nigram=0.95;

$url = "https://api.bitcoinaverage.com/ticker/ILS/";
$json = json_decode(file_get_contents($url), true);
$price = $json["last"];
?>

<head>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>

<input type="text" id="BTC" value="1">
<input type="text" id="ILS" value="">

<?

echo "<script>";
echo "$( \"#BTC\" )";
echo ".keyup(function() { var BTCprice = $( this ).val();";
echo "if($.isNumeric(BTCprice) === false) { this.value = this.value.slice(0,-1); }";
echo " $( \"#ILS\" ).val( BTCprice * ".$price * $margin." ); })";
echo ".keyup();";
echo "$( \"#ILS\" )";
echo ".keyup(function() { var ILSprice = $( this ).val();";
echo "if($.isNumeric(ILSprice) === false) { this.value = this.value.slice(0,-1); }";
echo "var ILSprice = ILSprice / ".$price / $nigram ."; var i = ILSprice.toFixed(8);";
echo " $( \"#BTC\" ).val( i ); })";
echo ".keyup();";
echo "</script>";
?>

sandaq (OP)
Member
**
Offline Offline

Activity: 72
Merit: 11


View Profile WWW
August 26, 2016, 05:02:36 PM
 #3

The above code has been implemented on my site. Check it out: https://www.spice.co.il/en/buy.php

amacar2
Legendary
*
Offline Offline

Activity: 1120
Merit: 1007

CryptoTalk.Org - Get Paid for every Post!


View Profile
August 26, 2016, 06:46:55 PM
 #4

The above code has been implemented on my site. Check it out: https://www.spice.co.il/en/buy.php
What actually is ILS? quite confusing but it seem script is working and enough to get exchange rate.

 
                                . ██████████.
                              .████████████████.
                           .██████████████████████.
                        -█████████████████████████████
                     .██████████████████████████████████.
                  -█████████████████████████████████████████
               -███████████████████████████████████████████████
           .-█████████████████████████████████████████████████████.
        .████████████████████████████████████████████████████████████
       .██████████████████████████████████████████████████████████████.
       .██████████████████████████████████████████████████████████████.
       ..████████████████████████████████████████████████████████████..
       .   .██████████████████████████████████████████████████████.
       .      .████████████████████████████████████████████████.

       .       .██████████████████████████████████████████████
       .    ██████████████████████████████████████████████████████
       .█████████████████████████████████████████████████████████████.
        .███████████████████████████████████████████████████████████
           .█████████████████████████████████████████████████████
              .████████████████████████████████████████████████
                   ████████████████████████████████████████
                      ██████████████████████████████████
                          ██████████████████████████
                             ████████████████████
                               ████████████████
                                   █████████
.YoBit AirDrop $.|.Get 700 YoDollars for Free!.🏆
sandaq (OP)
Member
**
Offline Offline

Activity: 72
Merit: 11


View Profile WWW
August 26, 2016, 08:06:53 PM
 #5

ILS is Israeli currency. about 3.7 ILS worth 1 USD.

Patatas
Legendary
*
Offline Offline

Activity: 1750
Merit: 1115

Providing AI/ChatGpt Services - PM!


View Profile
August 27, 2016, 07:43:43 AM
 #6

ILS is Israeli currency. about 3.7 ILS worth 1 USD.
Please change the blue background solid color from the website.Literally hurting my eyes.I kind of figured out 2757 ILS = 1 Bitcoin.So basically you sell bitcoins,how is anyone suppose to pay you from bank transfer without using a escrow ?
sandaq (OP)
Member
**
Offline Offline

Activity: 72
Merit: 11


View Profile WWW
August 27, 2016, 12:41:34 PM
 #7

Please change the blue background solid color from the website.Literally hurting my eyes.I kind of figured out 2757 ILS = 1 Bitcoin.So basically you sell bitcoins,how is anyone suppose to pay you from bank transfer without using a escrow ?

The background has been changed. I'm still developing the sites. The will also be a credit card ability to pay for bitcoins and probaby cash. We are a legit company just like you buy anything on the internet without escrow you can buy with us.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!