1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- require_once __DIR__ . "/SmsSenderUtil.php";
-
-
- class SmsVoiceVerifyCodeSender
- {
- private $url;
- private $appid;
- private $appkey;
- private $util;
-
-
-
- public function __construct($appid, $appkey)
- {
- $this->url = "https://cloud.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;
- if ($playtimes == 1) {
- $data->playtimes = 1;
- } else if ($playtimes == 3) {
- $data->playtimes = 3;
- } else {
- $data->playtimes = 2;
- }
-
-
- $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);
- }
- }
|