Author

Topic: total received counter for donations (Read 2291 times)

full member
Activity: 154
Merit: 100
April 23, 2011, 09:46:34 PM
#8
There's an API page for that:
http://blockexplorer.com/q/getreceivedbyaddress

I don't recommend scraping the HTML pages.

Neither do I.

Thanks for the API link; I searched Google unsuccessfully for blockexplorer API but that's as far as I went.

Update:

Code:

$donation_address
=$_GET['addr'];

$ch curl_init('http://blockexplorer.com/q/getreceivedbyaddress/'.$donation_address);
curl_setopt ($chCURLOPT_RETURNTRANSFER1) ;
$btc curl_exec($ch);

echo 
$btc;

die();

?>
administrator
Activity: 5222
Merit: 13032
April 23, 2011, 09:34:17 PM
#7
There's an API page for that:
http://blockexplorer.com/q/getreceivedbyaddress

I don't recommend scraping the HTML pages.
full member
Activity: 154
Merit: 100
April 23, 2011, 11:29:52 AM
#6
Forgot the disclaimer:

The above code is for example purposes only. It may contain huge security flaws and may cause your server to physically explode.


Anyway,  if noone else has a shot at it, I'll try to rewrite it at some point, and add some javascript/ajax to the mix.

It's a cool idea for a widget anyway, cheers.

legendary
Activity: 1372
Merit: 1002
April 23, 2011, 11:23:08 AM
#5
Cool. It seems easier than I thought.
full member
Activity: 154
Merit: 100
April 23, 2011, 11:12:42 AM
#4
Well, there is now... sort of.

I just put together this very nasty, barely tested bit of PHP to scrape the blockexplorer site for a given address's total received amount.

Code:

$donation_address
=$_GET['addr'];

$ch curl_init('http://blockexplorer.com/address/'.$donation_address);
curl_setopt ($chCURLOPT_RETURNTRANSFER1) ;
$html curl_exec($ch);
$html=substr($html,strpos($html,'Received BTC:')+14);
$btc=substr($html,0,strpos($html,''));

echo 
$btc;

die();

?>


If you save that on your site as totalbtc.php and give it an address like this:

totalbtc.php?addr=fivjiwejefijwiejwiejiwei

Then it will output the total received of that address.

As I said though, the above is downright crap code, just put together in the last few minutes... version 0.0.00.1a

Thought it might help get the ball rolling for other people's ideas anyway.

legendary
Activity: 1372
Merit: 1002
April 23, 2011, 10:57:43 AM
#3
I don't have a site. Just asking. Is there something like that for php?
full member
Activity: 154
Merit: 100
April 23, 2011, 10:52:36 AM
#2
Can you run PHP on the same site?
legendary
Activity: 1372
Merit: 1002
April 23, 2011, 10:43:26 AM
#1
Is there some javascript or something that you can add to your web and contains the following?

-bitcoin address to send donations
-Total amount of bitcoins sent to that address (It doesn't matter if they're gone).
-Total amount of bitcoins needed (optional)

I think it could be useful for some projects or pledges.
Jump to: