Connect to the Twizo API using PHP. This API includes functions to send verifications (2FA), SMS and Number Lookup.
- PHP >= 5.4
- Guzzle 5.3
- Composer
To use the Twizo API client, the following things are required:
- Create a Twizo account
- Login on the Twizo portal
- Find your application secret
- Find your nearest api node
The easiest way to start using the the Twizo API is to require it with Composer.
$ composer require twizo/lib-api-php
Use the auto loader to load all required classes. If you're using Composer, you can skip this step and use the composer auto loader.
require "autoload.php";
Initializing the Twizo Api using your api secret and api host
$twizo = Twizo\Api\Twizo::getInstance('43reFDSrewrfet425rtefdGDSGds54twegdsgHaFST2refwd', 'api-asia-01.twizo.com');
Create a new verification
$verification = $twizo->createVerification('610123456789');
$verification->send();
Verify token
try {
$result = $twizo->getTokenResult($verification->getMessageId(), '12345');
print 'Success' . PHP_EOL;
} catch (Verification\Exception $e) {
print 'Failed: ' . $e->getMessage() . PHP_EOL;
} catch (Twizo\Api\Exception $e) {
print 'Exception: ' . $e->getMessage() . PHP_EOL;
}
Send sms
$sms = $twizo->createSms('test message body', '610123456789', 'sender');
$sms->sendSimple();
In the examples directory you can find a collection of cli examples of how to use the api. When first running an example you will be asked for a host name and secret; this will be written to a config file.
The MIT License. Copyright (c) 2016-2017 Twizo
Contact: www.twizo.com — [email protected]