danvick/yii2-jumbefupi
Composer 安装命令:
composer require danvick/yii2-jumbefupi
包简介
Yii2 extension for integrating with JumbeFupi SMS Gateway
关键字:
README 文档
README
Yii2 extension for integrating with JumbeFupi SMS Gateway
Requirements
You need to register your account at JumbeFupi if you want to send messages to your users or customers. Sign up is FREE.
The JumbeFupi Gateway API credentials required (username, API key and senderID) will be available under the Developer page in your control panel.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist danvick/yii2-jumbefupi "*"
or add
"danvick/yii2-jumbefupi": "*"
to the require section of your composer.json file.
To always use the latest version from Github, in your composer.json, add this repository to the repositories section.
{
...
"repositories": [
{
"type": "vcs",
"url": "https://github.com/danvick/yii2-jumbefupi"
}
],
}
Usage
The extension is used as an application component and configured in the application configuration as such:
'components' => [ ... 'jumbefupi' => [ 'class' => JumbefupiGateway::class, 'gatewayUsername' => 'jaribujf', // REQUIRED - your JumbeFupi username 'gatewayApiKey' => 'Jum83fUp14pI_kEy', // REQUIRED - your JumbeFupi API key 'senderId' => 'JumbeFupi', // REQUIRED - your SenderID / Alphanumeric. If not set here, should be set when sending message 'callbackUrl' => null, // OPTIONAL - the URL where message status response from JumbeFupi Gateway will be sent 'model' => 'danvick\jumbefupi\models\SmsMessage', // OPTIONAL - (default: danvick\jumbefupi\models\SmsMessage) 'db' => 'db', // OPTIONAL - the DB connection component for the messages table 'cacheBalance' => false, // OPTIONAL - whether to store balance after enquiry - cache will be burst on message sending 'cache' => 'cache', // OPTIONAL - the cache component to store balance if cacheBalance is true 'balanceCacheKey' => 'JUMBEFUPI_BALANCE', // OPTIONAL - cache key for storage of JumbeFupi account balance 'useFileTransport' => false, // OPTIONAL - useful in local development 'fileTransportPath' => '@runtime/messages' // OPTIONAL - required if `useFileTransport` is true ], ]
You also should configure the extension migrations to be run in your application config by adding danvick\jumbefupi\migrations to your migrationNamespaces:
'controllerMap' => [ 'migrate' => [ 'class' => 'yii\console\controllers\MigrateController', ... 'migrationNamespaces' => [ ... 'danvick\jumbefupi\migrations' ], ], ],
Sending a message
Note:
yii2-jumbefupiextension uses theyii2-httpclientand 'baseUrl' is already set in the yii2-jumbefupi extension itself. The current API base URL ishttps://api.jumbefupi.com/v2
use danvick\jumbefupi\TextMessage; ... Yii::$app->jumbefupi->send(new TextMessage(['recipients' => $recipients, 'text' => $message]))
$recipients: A string of comma separated phone numbers or an array of phone number string
$message: Text message to send
$senderId (OPTIONAL): The alphanumeric SenderId shown as message sender to user. Optional if already set in jumbefupi component in config
Handling status callbacks / Check message status
You can either create an endpoint to handle message status callback so that when the message status changes (e.g. when message is delivered or otherwise) or manually calling getMessageStatus() function
-
Setting up a callback
Set up an action to handle callbacks from the gateway then update the message status in DB. It's important that this action be unauthenticated
The server response to the callback will take the following shape:
{ "message_id": "517E70B0F3A611EC84223E99B9487780", "phone_number": "0700000000", "cost": 1.0, "status": "queued", "status_message": "Added to queue", "sms_count": 1 } -
Manually calling
getMessageStatus()to get message statusYii::$app->jumbefupi->getMessageStatus($messageId)
$messageId: message identifier found within themessage_idcolumn in thesms_messagetableThe message will be automatically updated in the DB on successful server response.
Checking your JumbeFupi account balance
Returns your JumbeFupi account balance. The balance can be cached if cacheBalance is set to true in config. The cached balance if any will be deleted on sending message(s)
Yii::$app->jumbefupi->checkBalance($fromCache)
$fromCache: Boolean to enable getting cached balance if available or to ignore cached value. Only useful when cacheBalance is set to true in config
API Documentation
See the API documentation for more information here: JumbeFupi API Docs
danvick/yii2-jumbefupi 适用场景与选型建议
danvick/yii2-jumbefupi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 754 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 07 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 danvick/yii2-jumbefupi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 danvick/yii2-jumbefupi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 danvick/yii2-jumbefupi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
Define your own css rule-sets for the TYPO3 CMS backend.
统计信息
- 总下载量: 754
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-07-02