Bitcoin Forum
September 19, 2018, 02:35:35 AM *
News: ♦♦ Bitcoin Core users must update to 0.16.3 [Torrent]. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Displaying the current Bitcoin price  (Read 125 times)
LeGaulois
Copper Member
Hero Member
*****
Offline Offline

Activity: 826
Merit: 850

Bitcoin Ninja Unregulated Banker Unbanking Folks


View Profile
April 11, 2018, 05:29:15 PM
 #1

I need to install a code displaying the current Bitcoin price (and in future some other data related to Bitcoin)
I am using a WordPress installation.

So you may think, why not using the ready-made widgets such as coincompare bitcoinaverage and alike websites? I can't because they are branded (powered by.) And I can't use such method.

So then, why not to use APIs you say? Here is my problem:

How the fuck am I supposed to use the APIs?
I tried with different tags such as <src> <frame> and even I tried in a plain text (<==  Cheesy Yes I know)

Using a search engine is not so useful, I mainly find links related to the WordPress API, not how to use APIs with WP.
I wasted 2 hours searching for something that I know it's easy to do (once you know how)

Thank you Cry

1537324535
Hero Member
*
Offline Offline

Posts: 1537324535

View Profile Personal Message (Offline)

Ignore
1537324535
Reply with quote  #2

1537324535
Report to moderator
1537324535
Hero Member
*
Offline Offline

Posts: 1537324535

View Profile Personal Message (Offline)

Ignore
1537324535
Reply with quote  #2

1537324535
Report to moderator
1537324535
Hero Member
*
Offline Offline

Posts: 1537324535

View Profile Personal Message (Offline)

Ignore
1537324535
Reply with quote  #2

1537324535
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
LeGaulois
Copper Member
Hero Member
*****
Offline Offline

Activity: 826
Merit: 850

Bitcoin Ninja Unregulated Banker Unbanking Folks


View Profile
April 14, 2018, 08:22:54 PM
 #2

Anyone?  Huh

TryNinja
Hero Member
*****
Online Online

Activity: 770
Merit: 756


ChipMixer's Badge of Honor


View Profile
April 14, 2018, 08:39:16 PM
Merited by LeGaulois (2)
 #3

I'm not aware on how Wordpress works, but can you create a .PHP file and and host it in your website? You could create a .php file to parse out the price from an exchange/coinmarketcap/bitcoinaverage API and show it in your page (directly or through an iframe).

LeGaulois
Copper Member
Hero Member
*****
Offline Offline

Activity: 826
Merit: 850

Bitcoin Ninja Unregulated Banker Unbanking Folks


View Profile
April 14, 2018, 09:08:38 PM
 #4

Thanks dude. Yes, I can use PHP, so basically I create the file and just copy paste any API code inside and save? It's easy so, my only problem then is how to display it? is it what am I supposed to use on a page then?
https://www.google.com/search?q=how+to+call+a+php+function&oq=how+to+call+a+php+function&aqs=chrome..69i57j0l5.10327j0j7&sourceid=chrome&ie=UTF-8

through an iframe It didn't work but I think now I was using the URL and not an API code lol

bitcoinblog
Sr. Member
****
Offline Offline

Activity: 427
Merit: 251

BEST SITES


View Profile
April 15, 2018, 02:53:26 AM
 #5

If you want custom based then i can code for you in PHP which u can display anywhere u like

Or you can use readymade

https://wordpress.org/plugins/cryptocurrency-price-ticker-widget/

The keyword for search is Bitcoin Ticker or Cryptocurrency Ticker for wordpress.

https://wordpress.org/plugins/search/bitcoin-ticker-widget/

LeGaulois
Copper Member
Hero Member
*****
Offline Offline

Activity: 826
Merit: 850

Bitcoin Ninja Unregulated Banker Unbanking Folks


View Profile
April 17, 2018, 08:14:09 PM
 #6

Thanks for your offer but I prefer doing it myself as I am sure it isn't difficult. I don't want to use a plugin based solution as the WP installation I already overloaded with plugins which I usually don't like to have

TryNinja
Hero Member
*****
Online Online

Activity: 770
Merit: 756


ChipMixer's Badge of Honor


View Profile
April 17, 2018, 11:16:41 PM
Merited by LeGaulois (5)
 #7

Can you add your own PHP code inside the page?

If so, you could do something like this:

Code:
<?php  
  $url 
"https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=USD";

  
$json file_get_contents($url);
  
$data json_decode($jsonTRUE);

  
$btc_last  $data[0]["price_usd"];
?>


<ul>
   <li>Price: $<?php echo $btc_last ?></li>
</ul>

or if you can't, create a file called "price.php" or whatever with the same code and add something like this to your page:
Code:
<iframe width="300" height="300" frameBorder="0" src="price.php"></iframe>

or if you want to load it with Javascript and JQuery:

If you are not already using jquery in your page, add this to your <head> tag:
Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

And do something like this:
Code:
<div id="price"></div>

<script>
$(document).ready(function() {
    $("#price").load("price.php");
});
</script>

LeGaulois
Copper Member
Hero Member
*****
Offline Offline

Activity: 826
Merit: 850

Bitcoin Ninja Unregulated Banker Unbanking Folks


View Profile
April 18, 2018, 08:13:34 PM
 #8

Yeah, thanks buddy
Actually, both solutions will work. The first is the fastest I can include it in the theme, but I don't want to edit it as I am already facing a problem with it lol
The second one seems to be the best for my case, however, in


a PHP code can be included with <iframe.....src= ...>  Huh

TryNinja
Hero Member
*****
Online Online

Activity: 770
Merit: 756


ChipMixer's Badge of Honor


View Profile
April 18, 2018, 08:30:30 PM
 #9

In this case, you are loading the price.php page into your iframe. So, the price will be printed in the price.php and shown in the page where you set the iframe code.

Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!