tiniyo / tiniyo-php
There is no license information available for the latest version (v1.1.3) of this package.
php sdk for tiniyo api
v1.1.3
2021-01-18 09:39 UTC
Requires
- php: >=7.1.0
- twilio/sdk: ^6.16
README
tiniyo-php provides sdk for tiniyo apis.
Supported PHP Versions
This library supports the following PHP implementations:
- PHP 7.2
- PHP 7.3
- PHP 7.4
- PHP 8.0.1
Installation
You can install tiniyo-php via composer or by downloading the source.
Via Composer:
tiniyo-php is available on Packagist as the
tiniyo/tiniyo-php
package:
composer require tiniyo/tiniyo-php
Quickstart
Send an SMS
// Send an SMS using tiniyo's REST API and PHP <?php $sid = "ACXXXXXX"; // Your Account SID from https://tiniyo.com $token = "YYYYYY"; // Your Auth Token from https://tiniyo.com $client = new Tiniyo\Rest\Client($sid, $token); $message = $client->messages->create( '8881231234', // Text this number [ 'from' => '9991231234', // From a valid Tiniyo number or approved senderid 'body' => 'Hello from Tiniyo!' ] ); print $message->sid;
Make a Call
<?php $sid = "ACXXXXXX"; // Your Account SID from https://tiniyo.com $token = "YYYYYY"; // Your Auth Token from https://tiniyo.com $client = new Tiniyo\Rest\Client($sid, $token); // Read tinixml at this URL when a call connects (hold music) $call = $client->calls->create( '8881231234', // Call this number '9991231234', // From a valid Tiniyo number [ 'url' => 'https://raw.githubusercontent.com/tiniyo/public/master/answer_speak.xml' ] );
Enable Debug Logging
You can set the log level to debug to enable debug logging in the default HTTP client
$sid = "ACXXXXXX"; // Your Account SID from https://tiniyo.com $token = "YYYYYY"; // Your Auth Token from https://tiniyo.com $client = new Tiniyo\Rest\Client($sid, $token); $client->setLogLevel('debug');
Generating Tinixml
To control phone calls, your application needs to output Tinixml.
Use Tiniyo\Tinixml\(Voice|Messaging|Fax)Response
to easily chain said responses.
<?php $response = new Tiniyo\Tinixml\VoiceResponse(); $response->say('Hello'); $response->play('https://api.tiniyo.com/cowbell.mp3', ['loop' => 5]); print $response;
That will output XML that looks like this:
<?xml version="1.0" encoding="utf-8"?> <Response> <Say>Hello</Say> <Play loop="5">https://api.tiniyo.com/cowbell.mp3</Play> </Response>