Bitcoin Forum
March 29, 2024, 12:02:41 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin wordpress plugin for live mtgox pricing  (Read 2351 times)
CryptoGolfer (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0



View Profile WWW
April 26, 2012, 04:20:32 AM
 #1

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.
BitcoinCleanup.com: Learn why Bitcoin isn't bad for the environment
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1711713761
Hero Member
*
Offline Offline

Posts: 1711713761

View Profile Personal Message (Offline)

Ignore
1711713761
Reply with quote  #2

1711713761
Report to moderator
1711713761
Hero Member
*
Offline Offline

Posts: 1711713761

View Profile Personal Message (Offline)

Ignore
1711713761
Reply with quote  #2

1711713761
Report to moderator
1711713761
Hero Member
*
Offline Offline

Posts: 1711713761

View Profile Personal Message (Offline)

Ignore
1711713761
Reply with quote  #2

1711713761
Report to moderator
Tuxavant
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000

Bitcoin Mayor of Las Vegas


View Profile WWW
April 26, 2012, 01:06:12 PM
 #2

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:
<?php
        
//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']);

 
?>

<table border="0">
<tbody>
<tr>
<td style="text-align: center;" colspan="2">MTGOX</td>
<td style="text-align: center;" colspan="2">Weighted</td>
</tr>
<tr>
<td>Last:</td>
<td><?php echo $mtgox_array['last'];   ?></td>
<td>24h:</td>
<td><?php echo $bitcoincharts_array['24h']; ?></td>
</tr>
<tr>
<td>High:</td>
<td><?php echo $mtgox_array['high'];   ?></td>
<td>7d:</td>
<td><?php echo $bitcoincharts_array['7d']; ?></td>
</tr>
<tr>
<td>Low:</td>
<td><?php echo $mtgox_array['low'];   ?></td>
<td>30d:</td>
<td><?php echo $bitcoincharts_array['30d']; ?></td>
</tr>
<tr>
<td>Avg:</td>
<td><?php echo $mtgox_array['avg'];   ?></td>
<td>Volume:</td>
<td><?php echo $mtgox_array['vol'];   ?></td>
</tr>
</tbody>
</table>

CryptoGolfer (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0



View Profile WWW
April 26, 2012, 01:25:09 PM
 #3

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.

Tuxavant
Hero Member
*****
Offline Offline

Activity: 784
Merit: 1000

Bitcoin Mayor of Las Vegas


View Profile WWW
April 26, 2012, 01:44:42 PM
 #4

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.

CryptoGolfer (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0



View Profile WWW
April 26, 2012, 02:20:37 PM
 #5

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.
CryptoGolfer (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0



View Profile WWW
April 29, 2012, 03:00:20 AM
 #6

Any coders willing to take a crack at this for me?
CryptoGolfer (OP)
Newbie
*
Offline Offline

Activity: 12
Merit: 0



View Profile WWW
April 29, 2012, 11:06:37 PM
 #7

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:
<?php
$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
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!