12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace addons\qcloudsms\library;
- use addons\qcloudsms\library\SmsSenderUtil;
- class SmsVoiceVerifyCodeSender
- {
- private $url;
- private $appid;
- private $appkey;
- private $util;
-
- public function __construct($appid, $appkey)
- {
- $this->url = "https://yun.tim.qq.com/v5/tlsvoicesvr/sendvoice";
- $this->appid = $appid;
- $this->appkey = $appkey;
- $this->util = new SmsSenderUtil();
- }
-
- public function send($nationCode, $phoneNumber, $msg, $playtimes = 2, $ext = "")
- {
- $random = $this->util->getRandom();
- $curTime = time();
- $wholeUrl = $this->url . "?sdkappid=" . $this->appid . "&random=" . $random;
-
- $data = new \stdClass();
- $tel = new \stdClass();
- $tel->nationcode = "".$nationCode;
- $tel->mobile = "".$phoneNumber;
- $data->tel = $tel;
- $data->msg = $msg;
- $data->playtimes = $playtimes;
-
- $data->sig = hash("sha256",
- "appkey=".$this->appkey."&random=".$random."&time="
- .$curTime."&mobile=".$phoneNumber, FALSE);
-
- $data->time = $curTime;
- $data->ext = $ext;
- return $this->util->sendCurlPost($wholeUrl, $data);
- }
- }
|