Telerivet for Yii2
This component is YII2 wrapper for Telerivet PHP SDK., (*1)
Installation
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist open-ecommerce/yii2-telerivet "dev-master"
or if you have composer installed globaly, (*4)
composer require --prefer-dist open-ecommerce/yii2-telerivet "dev-master"
or add, (*5)
"open-ecommerce/yii2-telerivet": "dev-master"
to the require section of your composer.json
file., (*6)
Depending on your minimun composer requirements defined in your composer.json you will need to add the repository:, (*7)
"repositories": [
{
"type": "vcs",
"url": "https://github.com/open-ecommerce/yii2-telerivet"
},
...
Usage
Once the extension is installed, simply use it in your code by putting this in your config:, (*8)
'components' => array(
...
'Yii2Telerivet' => array(
'class' => 'openecommerce\yiiTelerivet\YiiTelerivet',
'account_sid' => getenv('Telerivet_ACCOUNT_SID'),
'auth_key' => getenv('Telerivet_AUTH_KEY'),
),
...
);
After you have configured a component, you can use it for example in this way:, (*9)
$TelerivetService = Yii::$app->Yii2Telerivet->initTelerivet();
try {
$message = $TelerivetService->account->messages->create(
"+12345678901", // To a number that you want to send sms
array(
"from" => "+12345678901", // From a number that you are sending
"body" => "Hello from my Yii2 Application!",
));
} catch (\Telerivet\Exceptions\RestException $e) {
echo $e->getMessage();
}
For more SDK functions and usage documentation feel free to visit official Telerivet PHP SDK documentation section here., (*10)
Resources
Telerivet.com, (*11)
If you have any questions, feel free to ask., (*12)