fourcoders / latch-sdk-php
PHP SDK for latch API with composer and guzzle
Requires
- php: >=5.3.3
- guzzlehttp/guzzle: ~5.0
This package is not auto-updated.
Last update: 2024-11-05 16:40:00 UTC
README
latch-sdk-php
Latch SDK php with Guzzle.
This library is 100% compatible with proyects with the original latch sdk https://github.com/ElevenPaths/latch-sdk-php. The feature of our library is that you can load it with the modern Composer system.
Installation
Install via Composer
{
"require": {
"fourcoders/latch-sdk-php": "dev-master"
}
}
Autoloading
Composer generates a vendor/autoload.php file. You can simply include this file and you will get autoloading for free.
require 'vendor/autoload.php';
Usage
Extract and modify of original php sdk https://github.com/ElevenPaths/latch-sdk-php#using-the-sdk-in-php
Create a Latch object with the "Application ID" and "Secret" previously obtained.
$api = new \Fourcoders\LatchSdk\Latch(APP_ID, APP_SECRET);
Optional settings:
$api->setProxy(YOUR_PROXY);
Call to Latch Server. Pairing will return an account id that you should store for future api calls
$pairResponse = $api->pair("PAIRING_CODE_HERE"); $statusResponse = $api->status(ACCOUNT_ID_HERE); $unpairResponse = $api->unpair(ACCOUNT_ID_HERE);
After every API call, get Latch response data and errors and handle them.
$pairResponse->getData(); $pairResponse->getError();