Bitcoin Forum
December 09, 2016, 07:27:34 PM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Bitcoin PHP [OPEN SOURCE]  (Read 7175 times)
schalk
Jr. Member
*
Offline Offline

Activity: 36


View Profile
May 22, 2011, 01:56:01 AM
 #1

Bitcoin Class (JSON-RPC Communication)
Integrating Bitcoin into your website can be hard at first and rather frustrating, this class was designed to make it easier and to ease confusion. This script simply connect to a Bitcoin Server and then send a command to get the balance of your account. As the title says it is opensource. I paid for a VPS yesterday which is currently being setup, once it is setup I will record a video demonstrating how to integrate Bitcoin into your website (because I love you guys Wink.

Link:
https://github.com/schalk-b/Simple-Bitcoin-PHP

API/Methods:
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list

How to run server:
https://en.bitcoin.it/wiki/Running_Bitcoin

Example:
Code:
include_once("Bitcoin.php");

$rpcUser = "username";
$rpcPass = "password";
$url = "http://localhost:8332";

// create bitcoin object
$bitcoin = new Bitcoin($url, $rpcUser, $rpcPass);

/**
 * Refer to https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
 * for a list of methods
 */
$balance = $bitcoin->getBalance();
echo("<p>Balance: $balance");

Donations
14bBEcMwwnDVXAYR8n2iTk9PTF5wqYLGR2

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
bitfreak!
Legendary
*
Offline Offline

Activity: 1514


electronic [r]evolution


View Profile WWW
May 22, 2011, 07:04:32 AM
 #2

So I still need to install Bitcoin on the web server?

Is there a public server I can use or something?

I am very new at this whole Bitcoin thing, but I love it too!

XCN: CYsvPpb2YuyAib5ay9GJXU8j3nwohbttTz | BTC: 18MWPVJA9mFLPFT3zht5twuNQmZBDzHoWF
Cryptonite - 1st mini-blockchain altcoin | BitShop - digital shop script
Web Developer - PHP, SQL, JS, AJAX, JSON, XML, RSS, HTML, CSS
schalk
Jr. Member
*
Offline Offline

Activity: 36


View Profile
May 22, 2011, 07:58:31 AM
 #3

Yeah bitcoins are so fascinating, take quite a bit to fully understand though.

From what I understand you can write a php script that connect to MtGox's API - https://mtgox.com/support/tradeAPI
This however does require you to have a mtgox account with "cash" on it.
carlerha
Sr. Member
****
Offline Offline

Activity: 252


View Profile
May 22, 2011, 03:10:08 PM
 #4

I don't see exactly what kind of work you did here, you copied the JSON-RPC-PHP class and changed the name of it? I'm sorry if I'm missing something.

matt.collier
Member
**
Offline Offline

Activity: 105



View Profile
May 22, 2011, 03:42:11 PM
 #5

This is excellent!

I have written a class that includes methods that interface with blockexplorer.com (http://blockexplorer.com/q).

Would these methods be welcome additions to this class?
schalk
Jr. Member
*
Offline Offline

Activity: 36


View Profile
May 22, 2011, 07:49:05 PM
 #6

Actually I didn't use the JSON-RPC-PHP class at all. I recreated this from scratch, since it is using the same kind of communication it will ofcourse have some similarities. One of the main differences are that this uses cURL instead of fopen and just has a nicer way of handling errors. Also, I know it's not much, but this one is case sensitive, I personally find getBalance() better practice then getbalance(). If you don't prefer this version, by all means do use the JSON-RPC-PHP verison.

@Matt: Smiley thanks mate. This class has MIT license so anyone can do with it what they want, if I have time I will see if I can develop a open source system like blockexplorer.com using this as a base class. I'm pretty busy at the moment though, still attending school.
matt.collier
Member
**
Offline Offline

Activity: 105



View Profile
May 22, 2011, 08:23:41 PM
 #7

Let me ask my question another way?

Are you looking for contributors to the project?  And if so, are methods that communicate with the blockexplorer.com API in keeping with the direction you would like to see this project take?

I could see incorporating methods that ease interfacing with any number of bitcoin related APIs (e.g. MTGOX, ClearCoin, BitcoinID)
carlerha
Sr. Member
****
Offline Offline

Activity: 252


View Profile
May 23, 2011, 08:18:42 AM
 #8

Actually I didn't use the JSON-RPC-PHP class at all. I recreated this from scratch, since it is using the same kind of communication it will ofcourse have some similarities. One of the main differences are that this uses cURL instead of fopen and just has a nicer way of handling errors. Also, I know it's not much, but this one is case sensitive, I personally find getBalance() better practice then getbalance(). If you don't prefer this version, by all means do use the JSON-RPC-PHP verison.
I had no intention of mocking you or saying that your php class was not good, it was just me thinking "why re-invent the wheel" etc. But hey, the incentive is great, and perhaps you'll even develop your script to a stage where it's really awesome! Smiley

zellfaze
Full Member
***
Offline Offline

Activity: 142


Security Enthusiast


View Profile WWW
May 25, 2011, 08:48:13 PM
 #9

I think the idea of using cURL instead of fopen() is a good idea if it means anything.

A+, CCENT, CCNA
Security Enthusiast
PHP Coder

Not that I expect anyone to, but should you like my post, please donate:
Donate: 1BRbfqii6Sm9tEUE8A16H7QeDmYFjyBZ7V
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!