1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?php
- namespace addons\qcloudsms\library;
- use addons\qcloudsms\library\SmsSenderUtil;
- class TtsVoiceSender
- {
- private $url;
- private $appid;
- private $appkey;
- private $util;
-
- public function __construct($appid, $appkey)
- {
- $this->url = "https://cloud.tim.qq.com/v5/tlsvoicesvr/sendtvoice";
- $this->appid = $appid;
- $this->appkey = $appkey;
- $this->util = new SmsSenderUtil();
- }
-
- public function send($nationCode, $phoneNumber, $templId, $params, $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->tpl_id = $templId;
- $data->params = $params;
- $data->playtimes = $playtimes;
-
- $data->sig = $this->util->calculateSig($this->appkey, $random,
- $curTime, array($phoneNumber));
-
- $data->time = $curTime;
- $data->ext = $ext;
-
- return $this->util->sendCurlPost($wholeUrl, $data);
- }
- }
|