kield-01 / smsc-ua-sms-sender
使用 SMSC.UA 服务为 CakePHP 3.3.x 发送 SMS/MMS/E-Mail/Viber/语音邮件消息
1.2.5.1
2016-11-27 14:30 UTC
Requires
- php: >=5.5
- cakephp/cakephp: 3.3.*
- fabpot/goutte: ^3.2
Suggests
- fabpot/goutte: Goutte/GuzzleHttp Client
This package is auto-updated.
Last update: 2024-09-29 04:08:53 UTC
README
如何安装此包?
composer require kield-01/smsc-ua-sms-sender dev-master
使用当前版本
使用此包需要什么?
- CakePHP 3.3.x
在需要此包后,将安装 fabpot/goutte
包
如何设置此组件?
有两种初始化选项
选项 1
在 config/app.php
中设置凭据密钥
'smsc_ua' => [
'login' => '__LOGIN__',
'psw' => '__PASSWORD__'
]
选项 2
在加载组件后设置凭据
use Cake\Controller\Component\SmscUaComponent;
/**
* Class X
*
* @property SmscUaComponent $SmscUa
**/
class X extends AppController
{
public function initialize(){
$this->loadComponent('SmscUa');
$this->SmscUa
->setLogin('__LOGIN__')
->setPassword('__PASSWORD__');
/** OR **/
$this->SmscUa
->setArgument('login', '__LOGIN__')
->setArgument('psw', '__PASSWORD__');
}
}
API
/** Allows You to add one number to current numbers list **/
$this->SmscUa->setNumbers('380666666666');
/** Allows You to add bulk to current numbers list **/
$this->SmscUa->setNumbers(['380666666666', '380666666667']);
/** Allows You to set message Text **/
$this->SmscUa->setMessageBody('Random text');
/** Allows You to change Response format **/
$this->SmscUa->setResponseFormat('string'); // Response as string data
$this->SmscUa->setResponseFormat('digits'); // Response as digits, separated by ','
$this->SmscUa->setResponseFormat('xml'); // Response as XML Document
$this->SmscUa->setResponseFormat('json'); // Response as JSON Object
/** Sending methods **/
$this->SmscUa->sendPlainTextSMS(); // Sending simple SMS