XP-PHP is a class for making calls to eXperience Points' RPC API using PHP.
-
Include xp-rpc.php into your PHP script:
require_once('xp-rpc.php');
-
Initialize eXperience Points connection/object:
$xp = new XPd('username','password');
Optionally, you can specify a host and port. Default is HTTP on localhost port 21892.
$xp = new XPd('username','password','localhost','21892');
If you wish to make an SSL connection you can set an optional CA certificate or leave blank
$xp->setSSL('/full/path/to/certificate.cert');
-
Make calls to XPd as methods for your object. Examples:
$xp->getinfo(); $xp->getrawtransaction('8669d910e1388d6e86b3e4f18b533748ba9f48add814128d47d9c367124c76a7',1); $xp->getblock('edb97f362767d3353537cec37ba49a6fb0c8dcd37a47df220f0542c1a34ad8e3');
-
When a call fails for any reason, it will return false and put the error message in
$xp->error
-
The HTTP status code can be found in
$xp->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
$xp->response
while the raw JSON is stored in$xp->raw_response