tooma/laravel-sms-api
Composer 安装命令:
composer require tooma/laravel-sms-api
包简介
Send and receive SMS anywhere in the world using our web services
README 文档
README
Send and receive SMS anywhere in the world using Tooma web services
Integrate TOOMA SMS API with Laravel
Laravel package to provide ntegration for TOOMA SMS service
Installation
Require this package with composer:
composer require tooma/laravel-sms-api
Once the package is added, add the ServiceProvider to the providers array in config/app.php:
Tooma\Laravel\Api\Providers\ToomaServiceProvider::class
Once done, publish the config to your config folder using:
php artisan vendor:publish --provider="Tooma\Laravel\Api\Providers\ToomaServiceProvider"
Configuration
Once the config file is published, open config/tooma-api.php
Edit config
Edit default configuration such as
apiKey : Your API key provider by Tooma
defaultSSLPath : Default path to ssl certificate if using a different certificate from default one
defaultSenderName : Default sender name defaults to TOOMA_SMS (in Kenya)
Usage
Retrive ApiKey
Once you get your API key, add it to the config/tooma-api.php config file, please note you only run this function once, you can also get your API key by going to tooma.co.ke > settings > api
app()->tooma->onSuccess(function($response,$pagination){
// Logic when Login is successfull
$apiKey = $response->data->token;
})->onError(function($response)
{
// Logic on Error
})->login(['username'=>'YOUR_USERNAME_OR_EMAIL','password'=>'YOUR_PASSWORD']);
Sending Message
Sending SMS is as easy as just
$parcel=[
['to'=>'+254XXXXXXXXX','message'=>'Greetings from Tooma'],
......
];
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
})->onError(function($response)
{
// Logic on Error
})->sendSms($parcel);
Sending Bulk Messages
Sending multiple message
$parcel=[
['to'=>'+254XXXXXXXXX','message'=>'Dear XXX Greetings from Tooma'],
['to'=>'+254YYYYYYYYY','message'=>'Dear YYY Greetings from Tooma'],
......
];
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
})->onError(function($response)
{
// Logic on Error
})->sendSms($parcel);
Retrive All Messages
Retrieve Message Status
Get account balancce
Getting balance just call balance as follows
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
echo "Your balance is $response->data->balance";
})->onError(function($response)
{
// Logic on Error
})->balance();
Send Message from CSV files
You can also send message from a csv file as follows
$csvPath = "path/to/your/csv.csv";
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
echo "Your balance is $response->data->balance";
})->onError(function($response)
{
// Logic on Error
})->withCsv($csvPath)
->withPhoneColumn('phone') //name of column with phone
->withTemplate('Dear :username_column_name your account balance is :balance_column_name')
->sendCsv();
Working with Message templates
You can also send message from a saved or new templat as follows
$data = [
['phone'=>'+254WWWWW','name'=>'','other_args'=>'args_val'];
];
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
echo "Your balance is $response->data->balance";
})->onError(function($response)
{
// Logic on Error
})->withParams(['args1'=>'val']) //extra parametaer
->withTemplate('Dear :name your account balance is :balance_column_name') //or you can pass a template id
->sendFromTemplate($data);
Schedule Message
You can send SMS at a later stage by enableing schedule, the shedule format follows the cron format
$parcel=[
['to'=>'+254XXXXXXXXX','message'=>'Greetings from Tooma'],
......
];
app()->tooma->onSuccess(function($response,$pagination){
// Logic sending is successfull
echo "Your balance is $response->data->balance";
})->onError(function($response)
{
// Logic on Error
})->schedule("FORMART")
->sendSms($parcel);
Support
Feel free to post your issues in the issues section.
tooma/laravel-sms-api 适用场景与选型建议
tooma/laravel-sms-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 06 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「send」 「receive」 「laravel」 「text message」 「tooma」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tooma/laravel-sms-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tooma/laravel-sms-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tooma/laravel-sms-api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Extensible library for building notifications and sending them via different delivery channels.
yii2-sms expand
Yii2 PlaymobileUz SMS-shlyuz
Playmobile sms service
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-06-13