mediumart/orange-sms
Composer 安装命令:
composer require mediumart/orange-sms
包简介
A php library to interact with the orange sms api for MiddleEast and Africa.
关键字:
README 文档
README
Description
A php library to interact with the orange sms api for MiddleEast and Africa.
Installation
Using composer:
$ composer require mediumart/orange-sms
Usage
First you need to resolve a SMSClient instance:
use Mediumart\Orange\SMS\SMS; use Mediumart\Orange\SMS\Http\SMSClient; /** * if you already have a valid access token * */ $client = SMSClient::getInstance('<your_access_token>'); // OR /** * directly using <client_id> and <client_secret> * */ $client = SMSClient::getInstance('<client_id>', '<client_secret>');
next step, create an SMS object passing it the $client :
$sms = new SMS($client);
and you're good to go:
// prepare and send an sms in a fluent way $sms->message('Hello, my dear...') ->from('+237690000000') ->to('+237670000000') ->send();
You now have access to the full orange sms api through the $sms object :
// sending SMS. $response = $sms->to('+237670000000') ->from('+237690000000', <'optional_sender_name>') ->message('Hello, world!') ->send(); // checking your balance(remaining sms units) // with optional country code filter ie: CIV $response = $sms->balance('<country_code>'); // checking SMS orders history // with optional country code filter ie: CMR $response = $sms->ordersHistory('<country_code>'); // checking SMS statistics // with optional country code filter // and optional appID filter $response = $sms->statistics('<country_code>', '<app_id>'); // setting the SMS DR notification endpoint // '<your_backend_notification_url>' $url // '<sender address>' $sender = '+237690000000' $response = $sms->setDeliveryReceiptNotificationUrl($url, $sender); // checking the SMS DR notification endpoint // '<your_last_registered_endpoint_ID>' $id $response = $sms->checkDeliveryReceiptNotificationUrl($id); // delete the SMS DR notification endpoint // '<last_registered_endpoint_ID>' $id // '<sender address>' $sender = '+237690000000' $response = $sms->deleteDeliveryReceiptNotificationUrl($id, $sender);
All json responses will automatically be converted to array.
Be sure to lookup the official documentation, to see what to expect as a response to each call.
Access Token
When you resolve the SMSClient instance using your client_id and client_secret, a new access token will be fetched from the api server and automatically set on the instance, along with its lifetime in seconds.
We recommend saving the token (maybe to your database) for future use, at least within the limit of its validity period. this will help speed up requests to the api.
Use the getToken() and getTokenExpiresIn() to get those values from the instance:
use Mediumart\Orange\SMS\Http\SMSClient; $client = SMSClient::getInstance('<client_id>', '<client_secret>'); // get the token $token = $client->getToken(); // get the token lifetime in seconds $tokenExpiresIn = $client->getTokenExpiresIn();
If you wish, you can also fetch your access token directly without resolving a client instance, using the static authorize method:
$response = SMSClient::authorize('<client_id>', '<client_secret>');
this will return as $response, an array of this form:
[ "token_type" => "Bearer", "access_token" => "i6m2iIcY0SodWSe...L3ojAXXrH", "expires_in" => "7776000" ]
SSL Certificate check issue
If you experience ssl certificate checking issue, in your local environment. You can disable the check temporarily with the following line, before starting to interact with the api in your code.
Just for testing purposes though. You should never do this on a production server.
\Mediumart\Orange\SMS\Http\SMSClientRequest::verify(false);
License
Mediumart orange-sms is an open-sourced software licensed under the MIT license.
mediumart/orange-sms 适用场景与选型建议
mediumart/orange-sms 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.41k 次下载、GitHub Stars 达 13, 最近一次更新时间为 2017 年 03 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sms」 「orange」 「orange-api」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mediumart/orange-sms 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mediumart/orange-sms 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mediumart/orange-sms 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
OUDS Web is a Bootstrap based, Orange branded accessible and ergonomic components library.
PHP library for sending SMS through various gateways
Laminas module for sending SMS messages
SDK for payment gateway PlatbaMobilom.sk for PHP7.0
Symfony Orange Sms Notifier Bridge
A laravel wrapper/adapter for orange api services.
统计信息
- 总下载量: 11.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 13
- 点击次数: 19
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-24