2017 © Pedro Peláez
 

library factom-api-php

A simple PHP wrapper for the Factom API

image

1000nettles/factom-api-php

A simple PHP wrapper for the Factom API

  • Friday, October 27, 2017
  • by 1000nettles
  • Repository
  • 1 Watchers
  • 1 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 18 % Grown

The README.md

factom-api-php

A Simple PHP Wrapper for any Factom API v2 calls (including calls to factomd and factom-walletd), (*1)

Find the Factom API reference documentation here: https://docs.factom.com/api, (*2)

Installation

Using Composer:, (*3)

composer require 1000nettles/factom-api-php, (*4)

Normal Require:, (*5)

require_once('FactomAPIAdapter.php');

How To Use

Launch any Factom Command-Line Apps

The PHP Factom API integration connects to a locally running instance of factomd or factom-walletd. When you run these locally or on your server, they run as service which lets you connect usually through http://localhost:8088 (factomd) or http://localhost:8089 (factom-walletd). You can find out more about running these services here - https://docs.factom.com/cli, (*6)

For factomd, you may be able to connect to "courtesy nodes" instead such as http://courtesy-node.factom.com, however these are not guaranteed. I have not tested if there are API limits. For more information: https://docs.factom.com/#run-enterprise-wallet-online, (*7)

Instantiate the Factom API Adapter

Notice we are supplying the full URL to version 2 of the API below., (*8)

$url = 'http://localhost:8088/v2';
$adapter = new FactomAPIAdapter($url);

If you want to interact with the API securely, make sure you're running factomd with TLS mode ON - ./factomd -tls true. You also should pass in the location to your certificate when instantiating the adapter, and change the URL to HTTPS:, (*9)

$url = 'https://localhost:8088/v2';
$certLocation = '~/.factom/m2/factomdAPIpub.cert';
$adapter = new FactomAPIAdapter($url, $certLocation);

If you want to interact with the API with a username and password, make sure you're running factomd with a username and password defined - ./factomd -rpcuser <username> -rpcpass <password>. You can run this with a certificate as well if you wish., (*10)

$url = 'https://localhost:8088/v2';
$username = 'user';
$password = 'password';
$adapter = new FactomAPIAdapter($url, null, $username, $password);

Run the API Method With Your Parameters!

API methods are outlined here: https://docs.factom.com/api, (*11)

$method = 'POST';
$result = $adapter->call('transaction', $method, array('hash' => '64251aa63e011f803c883acf2342d784b405afa59e24d9c5506c84f6c91bf18b'));

Firing GET Requests

Certain API methods use the GET method rather than POST. For example, the 'address' method within factom-walletd: https://docs.factom.com/api#address. You can run this easily:, (*12)

$method = 'GET';
$result = $adapter->call('address', $method, array('address' => 'FA2jK2HcLnRdS94dEcU27rF3meoJfpUcZPSinpb7AwQvPRY6RL1Q'));

That's all there is to it. If you are getting cURL issues, it may be because you do not have the PHP cURL lib installed., (*13)

Tests

Sorry! None right now., (*14)

Known Issues

  • Currently if you are using a secure connection (TLS) and you provide the path to a certificate, we ignore cURL self-signing certificate warnings via setting CURLOPT_SSL_VERIFYPEER to false.
  • The debug API endpoints are not accessible via this wrapper

The Versions

27/10 2017

dev-master

9999999-dev https://github.com/1000nettles/factom-api-php

A simple PHP wrapper for the Factom API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0
  • ext-curl *

 

by Avatar 1000nettles

api php factom factomd factom-walletd

27/10 2017

0.1.1

0.1.1.0 https://github.com/1000nettles/factom-api-php

A simple PHP wrapper for the Factom API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0
  • ext-curl *

 

by Avatar 1000nettles

api php factom factomd factom-walletd

18/08 2017

0.1.0

0.1.0.0 https://github.com/1000nettles/factom-api-php

A simple PHP wrapper for the Factom API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0
  • ext-curl *

 

by Avatar 1000nettles

api php factom factomd factom-walletd