123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <?php
- namespace addons\qcloudsms\library;
- use addons\qcloudsms\library\SmsSenderUtil;
- class SmsMultiSender
- {
- private $url;
- private $appid;
- private $appkey;
- private $util;
-
- public function __construct($appid, $appkey)
- {
- $this->url = "https://yun.tim.qq.com/v5/tlssmssvr/sendmultisms2";
- $this->appid = $appid;
- $this->appkey = $appkey;
- $this->util = new SmsSenderUtil();
- }
-
- public function send($type, $nationCode, $phoneNumbers, $msg, $extend = "", $ext = "")
- {
- $random = $this->util->getRandom();
- $curTime = time();
- $wholeUrl = $this->url . "?sdkappid=" . $this->appid . "&random=" . $random;
- $data = new \stdClass();
- $data->tel = $this->util->phoneNumbersToArray($nationCode, $phoneNumbers);
- $data->type = $type;
- $data->msg = $msg;
- $data->sig = $this->util->calculateSig($this->appkey, $random,
- $curTime, $phoneNumbers);
- $data->time = $curTime;
- $data->extend = $extend;
- $data->ext = $ext;
- return $this->util->sendCurlPost($wholeUrl, $data);
- }
-
- public function sendWithParam($nationCode, $phoneNumbers, $templId, $params,
- $sign = "", $extend = "", $ext = "")
- {
- $random = $this->util->getRandom();
- $curTime = time();
- $wholeUrl = $this->url . "?sdkappid=" . $this->appid . "&random=" . $random;
- $data = new \stdClass();
- $data->tel = $this->util->phoneNumbersToArray($nationCode, $phoneNumbers);
- $data->sign = $sign;
- $data->tpl_id = $templId;
- $data->params = $params;
- $data->sig = $this->util->calculateSigForTemplAndPhoneNumbers(
- $this->appkey, $random, $curTime, $phoneNumbers);
- $data->time = $curTime;
- $data->extend = $extend;
- $data->ext = $ext;
- return $this->util->sendCurlPost($wholeUrl, $data);
- }
- }
|