Updated April 3, 2019 -sample.php -Sample verification system using the EasyChaincoin class. -Live sample website: https://www.chaincoinisland.com/verify/
A simple class for making calls to Chaincoin's API using PHP.
-
Include easychaincoin.php into your PHP script:
require_once('easychaincoin.php');
-
Initialize Chaincoincoin connection/object:
$chaincoin = new Chaincoin('username','password');
Optionally, you can specify a host, port. Default is HTTP on localhost port 11995.
$chaincoin = new Chaincoin('username','password','localhost','11995');
If you wish to make an SSL connection you can set an optional CA certificate or leave blank
$chaincoin->setSSL('/full/path/to/mycertificate.cert');
-
Make calls to chaincoind as methods for your object. Examples:
$chaincoin->getinfo(); $chaincoin->getrawtransaction('0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098',1); $chaincoin->getblock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');
-
When a call fails for any reason, it will return false and put the error message in
$chaincoin->error
-
The HTTP status code can be found in $chaincoin->status and will either be a valid HTTP status code or will be 0 if cURL was unable to connect.
-
The full response (not usually needed) is stored in
$chaincoin->response
while the raw JSON is stored in$chaincoin->raw_response