PHP code example of yangwenqu / ztsms
1. Go to this page and download the library: Download yangwenqu/ztsms library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
yangwenqu / ztsms example snippets
namespace App\Http\Controllers;
use Yangwenqu\ZtSms\ZtSms;
class DemoController
{
public function index()
{
try {
//第一次实例的时候会需要构造参数,可在基类里提前把实例创建起来,在后面的使用中则不需要传入构造参数
$ztsms = ZtSms::getInstance('username','password');
//获取余额信息
$blance = $ztsms->getBalance();
//发送自定义短信,第二个参数必须包含签名【xxxx】
$res = $ztsms->sendCustomizeMsg('phone',"【这里是签名】尊重的用户您好,您的验证码是:123456,请妥善保管!");
if($res){
//成功
}
}catch (\Exception $e){
var_dump($e->getMessage());
}
}
}