Bitcoin Forum
November 17, 2024, 08:09:20 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [GUIDE] How to Make ANY Altcoin Price Converter in 2 Mins! [HTML/PHP]  (Read 1272 times)
Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 09, 2016, 11:26:51 PM
 #1

Introduction:
Original Thread: https://bitcointalk.org/index.php?topic=1464205.0

Hello All, Today i am going to tell you how to make your own altcoin currency converter using PHP and HTML. I know it seems to be difficult but when you understand it properly, it becomes a small piece of work for you. I will simply use https://www.cryptonator.com/api to make it work. Let's Go.

Steps to Follow:
Kindly follow all the steps and read carefully to understand the meaning of each and every word, so it would be easier to do it yourself.

Step 1 - A Basic HTML Page:
First of all, You should create a basic HTML Page like this in any of your text editor:
Code:
<html>
<head>
<title>Litecoin Price Converter</title>
</head>

<body>
</body>

</html>

Step 2 - PHP Script:
Now we will put PHP Coding to grab data using API. If you are not aware what is an API, Check this video: What is an API?
Let's start with creating a variable "$url". This variable will be used to grab data from the API Link i.e. https://www.cryptonator.com/api/ticker/ltc-usd
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
?>

Once we get our data from the API, We will have to decode it using JSON. Create a variable called $price in which we will store our decoded information.
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
$price json_decode(file_get_contents($url), true);
?>

At this moment we have the API's Information in the variable called $price, It's time to get an exact data which we want i.e. last price. We will create a new variable called $latest_price and will store the price in it.
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
$price json_decode(file_get_contents($url), true);
$ticker $data['ticker'];
$latest_price $ticker['price'];
?>

You did it, we got all the data and it's time to show it. Simply use echo function of PHP to output the data:
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
$price json_decode(file_get_contents($url), true);
$ticker $data['ticker'];
$latest_price $ticker['price'];
echo 
"$latest_price";
?>

Step 3 - Integrate HTML with PHP:
Now put the PHP Code on the top of the HTML Page we created before like this:
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
$data json_decode(file_get_contents($url), true);
$ticker $data['ticker'];
$latest_price $ticker['price'];
echo 
"$latest_price";
?>


<html>
<head>
<title>Litecoin Price Converter</title>
</head>

<body>
</body>

</html>

Step 4 - Auto Refresh Page (credit goes to KenR to remind me about this)
Our Converter is ready, we are going to add an auto refresh code to make it display the latest values. Simply add this code:
Code:
<meta content='10' http-equiv='refresh'/> <!-- Reloads Page every 10 seconds -->

FINAL:
That's what we get!
Code:
<?php 
$url 
"https://www.cryptonator.com/api/ticker/ltc-usd";
$data json_decode(file_get_contents($url), true);
$ticker $data['ticker'];
$latest_price $ticker['price'];
echo 
"$latest_price";
?>


<html>
<head>
<title>Litecoin Price Converter</title>
<meta content='10' http-equiv='refresh'/> <!-- Reloads Page every 10 seconds -->
</head>

<body>
</body>

</html>

Changing Altcoin:
Simply change the url from /ltc-usd to /altcoin-usd (Example: https://www.cryptonator.com/api/ticker/doge-usd)

Tada! You did it Wink



Hope this Guide helped you in understanding the concept of API's, Drop me some comments to motivate Smiley
If you want to Donate, Please: 18L6tGTdJfCenGxzc8ZDLsjBNaUfekXzjj
locopao
Legendary
*
Offline Offline

Activity: 910
Merit: 1000



View Profile
May 09, 2016, 11:40:57 PM
 #2

just another excellent tutorial by Th0ur007 !!!

Keep them coming! Thumbs up!

(i'll post a simple use of your code as a sidebar widget for wordpress with some css added, later on  Wink)
Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 09, 2016, 11:52:49 PM
 #3

just another excellent tutorial by Th0ur007 !!!

Keep them coming! Thumbs up!

(i'll post a simple use of your code as a sidebar widget for wordpress with some css added, later on  Wink)
Thanks alot mate, And ye!
I like your widget.

Cheers.
locopao
Legendary
*
Offline Offline

Activity: 910
Merit: 1000



View Profile
May 10, 2016, 07:39:12 AM
Last edit: May 10, 2016, 08:34:41 AM by locopao
 #4

can you add a "if / else" statement, too?

so if the "change" is >0 then a green up arrow shows
else "change" is <0 then a re down arrow shows

so with a few modifications and a little css help this would be the result:

Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 10, 2016, 08:41:39 AM
 #5

can you add a "if / else" statement, too?

so if the "change" is >0 then a green up arrow shows
else "change" is <0 then a re down arrow shows

so with a few modifications and a little css help this would be the result:


Nice work bro, i liked it.
hoop
Legendary
*
Offline Offline

Activity: 1524
Merit: 1001


NOBT - WNOBT your saving bank◕◡◕


View Profile WWW
May 10, 2016, 11:15:09 AM
 #6

can you add a "if / else" statement, too?

so if the "change" is >0 then a green up arrow shows
else "change" is <0 then a re down arrow shows

so with a few modifications and a little css help this would be the result:


Nice work bro, i liked it.
Both of you are awesome. very useful tutorial.

            ██████████  ██████████▄▄
         █████████████  ██████████████▄▄
   ▄███  █████▄                  ▀▀███████▄
  ██████   ▀█████▄          ████     ▀▀█████
 █████        ▀█████▄       ████        █████
 ████            ▀████      ████         ████
 ████         ██▄   ▀█  ██▄ ████         ████
 ████▌        █████▄    ████████        ▐████
 ▐████        ████████    ▀█████        ████▌
  █████       ████ ▀██  █▄   ▀██       █████
   █████      ████      ████▄         █████
    █████▄    ████       ▀█████▄    ▄█████
     ▀█████▄  ████          ▀█████▄   ██▀
       ▀█████▄                 ▀█████
         ▀██████▄▄          ▄▄██████▀
            ▀▀████████  ████████▀▀
                ▀▀████  ████▀▀
Take care of your financial privacy
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
A blockchain loyalty scheme and more
██
██
██
██
██
██
██
██
██
██
██
██


███████████████
███          ██████████████████
████████████████████████████████
███                          ███
███                          ███
███             ██           ███
███       ██   ██   ██       ███
███      ██    ██    ██      ███
███       ██  ██    ██       ███
███                          ███
███                          ███
████████████████████████████████


           ████    ████
       █████████ ████████
                           
████████████████████████████
█████████████████████████████
██████████████████
██████████████████ ███████████
██████████████████ ██    █████
██████████████████ ███████████
██████████████████
█████████████████████████████
████████████████████████████


        ▄█████▄
      ▄█████████
     ████    ███▌
    ███       ██▌
   ▐██ ███  ████
   ▄███████████
  ███████████▀
 ████  ███ ██▌
▐██       ███
▐███    ████
 █████████▀
  ▀█████▀
██
██
██
██
██
██
██
██
██
██
██
██
ANN         Discord
Twitter    Telegram
Nobt-plataform
dquancey
Hero Member
*****
Offline Offline

Activity: 586
Merit: 500


View Profile
May 10, 2016, 12:12:13 PM
 #7

Great tutorial, thanks for posting.

Going to mess around and put some CSS in there to tidy it up a little Smiley
Th0ur007 (OP)
Full Member
***
Offline Offline

Activity: 210
Merit: 101


View Profile
May 10, 2016, 12:34:13 PM
 #8

can you add a "if / else" statement, too?

so if the "change" is >0 then a green up arrow shows
else "change" is <0 then a re down arrow shows

so with a few modifications and a little css help this would be the result:


Nice work bro, i liked it.
Both of you are awesome. very useful tutorial.
Thanks for the comment, glad you liked it.

Great tutorial, thanks for posting.

Going to mess around and put some CSS in there to tidy it up a little Smiley
Haha, good luck with that.
Cheers.
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!