1,发送短信片段代码
$p = new ServerAPI(self::KEY,self::SECRET);
$res=$p->sendSmsCode($templateid,$mobile,'','',$authCode);
$authCode参数为自定义验证码
注意:
官方demo上创建的serverAPI为fsockopen,当使用fsockopen时$authCode参数不能直接传参, 默认使用curl调用。
以下为官方demo:
<?php/** * 发送模板短信 * @author chensheng***///使用示例require('./ServerAPI.php');//网易云信分配的账号,请替换你在管理后台应用下申请的Appkey$AppKey = 'fd460d34e786e7754e505bc4fab0f027';//网易云信分配的账号,请替换你在管理后台应用下申请的appSecret$AppSecret = 'xxxxxxxx';$p = new ServerAPI($AppKey,$AppSecret,'fsockopen'); //fsockopen伪造请求//发送短信验证码print_r( $p->sendSmsCode('6272','13888888888','','5') );//发送模板短信print_r( $p->sendSMSTemplate('6272',array('13888888888','13666666666'