Author

Topic: Bitcoin wordpress plugin for live mtgox pricing (Read 2364 times)

newbie
Activity: 12
Merit: 0
Code already written for it...believe this is functional... Will it work in a wordpress site?


Source for similar script if you want to host it yourself, requires php gd & json.
Code:
$opts = array(
  
'http'=> array(
    
'method'=>   "GET",
    
'user_agent'=>    "MozillaXYZ/1.0"));
$context stream_context_create($opts);
$json file_get_contents('https://mtgox.com/code/data/ticker.php'false$context);
$jdec json_decode($json);
$ppbtc round($_GET["usd"]/$jdec->{'ticker'}->{'sell'}, 2);
$length strlen($ppbtc);
//add [$length += 3;] if you want "BTC" at the end:
$im imagecreatetruecolor(($length*8), 13);
$bg imagecolorallocate($im000);
$black imagecolorallocate($im100);
imagecolortransparent($im$bg);
imagestring($im400$ppbtc ."BTC"$black);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>


Code:
[img]http://74.63.229.70/convert.php?usd=10[/img]
http://74.63.229.70/convert.php?usd=10
newbie
Activity: 12
Merit: 0
Any coders willing to take a crack at this for me?
newbie
Activity: 12
Merit: 0
Well sure, but I have no idea how to take that price and make it change automatically. For instance, I sell a club for $100 USD, divide that by the current gox price of 5.07 = 19.72 BTC. If the gox price changes to $2..I want my price to automatically adjust to $100/2= 50 BTC. Not sure how to do that using my wordpress flexishop theme. There is merely a box where I put the price in and that's the price..period. If I want it to change, I have to go into each "product" page and change it manually.
hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
The 24h weighted prices is stored in

Code:
$bitcoincharts_array['24h'];

Forget the table stuff.. Just divide your dollar price by that value and you've got the price in BTC.
newbie
Activity: 12
Merit: 0
Thanks but I've got that already displayed on my homepage. I need a way for my item's base prices to automatically change with the fluctuations in bitcoin price..don't want to have to have myself or customers doing calculations with usd to find out how much their order is going to be. Thank you though.

hero member
Activity: 784
Merit: 1010
Bitcoin Mayor of Las Vegas
I have some PHP at coinbus.com that displays live and weighted prices. It was derived, if not flat out plagiarized from some other code here on the forums. You're welcome to it.

Code:
        //first fetch the current rate from https://mtgox.com/api/0/data/ticker.php
        
$ch curl_init('https://mtgox.com/api/0/data/ticker.php');
                
curl_setopt($chCURLOPT_REFERER'Mozilla/5.0 (compatible; MtGox PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
                
curl_setopt($chCURLOPT_USERAGENT"CakeScript/0.1");
                
curl_setopt($chCURLOPT_HEADER0);
                
curl_setopt($chCURLOPT_RETURNTRANSFER1);
                
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
                
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                
$mtgoxjson curl_exec($ch);
                
curl_close($ch);
               
        
//decode from an object to array
                
$output_mtgox json_decode($mtgoxjson);
                
$output_mtgox_1 get_object_vars($output_mtgox);
                
$mtgox_array get_object_vars($output_mtgox_1['ticker']);


        
//first fetch the current rate from http://bitcoincharts.com/t/weighted_prices.json
        
$ch curl_init('http://bitcoincharts.com/t/weighted_prices.json');
                
curl_setopt($chCURLOPT_REFERER'Mozilla/5.0 (compatible; BitcoinCharts PHP client; '.php_uname('s').'; PHP/'.phpversion().')');
                
curl_setopt($chCURLOPT_USERAGENT"CoinBus.com/0.1");
                
curl_setopt($chCURLOPT_HEADER0);
                
curl_setopt($chCURLOPT_RETURNTRANSFER1);
                
curl_setopt($chCURLOPT_SSL_VERIFYHOSTfalse);
                
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                
$bitcoinchartjson curl_exec($ch);
                
curl_close($ch);
               
        
//decode from an object to array
                
$output_bitcoincharts json_decode($bitcoinchartjson);
                
$output_bitcoincharts_1 get_object_vars($output_bitcoincharts);
                
$bitcoincharts_array get_object_vars($output_bitcoincharts_1['USD']);

 
?>
































MTGOXWeighted
Last:echo $mtgox_array['last'];   ?>24h:echo $bitcoincharts_array['24h']; ?>
High:echo $mtgox_array['high'];   ?>7d:echo $bitcoincharts_array['7d']; ?>
Low:echo $mtgox_array['low'];   ?>30d:echo $bitcoincharts_array['30d']; ?>
Avg:echo $mtgox_array['avg'];   ?>Volume:echo $mtgox_array['vol'];   ?>

newbie
Activity: 12
Merit: 0
I'm not sure if this post in the correct location. I know little about coding and I am trying to find a WP plugin, code, etc that allows me to set a base price for items on my website, then the price automatically changes daily/hourly with respect to the current bitcoin price.

For instance, I post a golf club that is $100 USD. In bitcoins currently this would sell for $100/$5.099 current gox price in USD = 19.61 BTC. So if the price of btc jumps to $10 or god forbid $2 again..the price of my items automatically adjust. I will have literally hundreds of different items on my site soon and it would be way too much work to adjust the price daily for each one.

Can anyone help me with this? There are some sites that I see out there that I would think have already implemented this.. Coinabul perhaps?

I will obviously pay for a successful plugin/implementation of this feature.
Jump to: