123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace addons\qcloudsms\library;
- use addons\qcloudsms\library\SmsSenderUtil;
- class FileVoiceSender
- {
- private $url;
- private $appid;
- private $appkey;
- private $util;
-
- public function __construct($appid, $appkey)
- {
- $this->url = "https://cloud.tim.qq.com/v5/tlsvoicesvr/sendfvoice";
- $this->appid = $appid;
- $this->appkey = $appkey;
- $this->util = new SmsSenderUtil();
- }
-
- public function send($nationCode, $phoneNumber, $fid, $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->fid = $fid;
- $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);
- }
- }
|