twizo / lib-api-php
Library to connect to Twizo to send SMS, Number Lookup or Verifications
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Requires
- php: ^5.4|^7.0
- ext-curl: *
- ext-json: *
- ext-openssl: *
- ext-spl: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Twizo PHP API
Connect to the Twizo API using PHP. This API includes functions to send verifications (2FA), SMS and Number Lookup.
Requirements
- PHP >= 5.4
- Composer
Get application secret and api host
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
Installation
The easiest way to start using the the Twizo API is to require it with Composer.
$ composer require twizo/lib-api-php
Getting started
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();
Examples
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.
License
The MIT License. Copyright (c) 2016-2017 Twizo
Support
Contact: www.twizo.com — support@twizo.com