今天测试云之讯api 云之讯官网提供源码只需要修改就好
我的是放入tp5路径如下:前端代码脑补 只有一个input和按钮
直接上代码
index.php
<?php
namespace app\admin\controller;
use think\Db;
use think\Loader;
use think\Controller;
use app\admin\controller\PhoneSend;
class Index extends Controller
{
public function index()
{
return $this->fetch();
}
public function set(){
// var_dump($_POST);
$obj = new PhoneSend();
$obj->text();
}
}
PhoneSend.php
<?php
namespace app\admin\controller;
use app\admin\controller\Ucpass;
class PhoneSend{
public function text(){
//初始化必填
//填写在开发者控制台首页上的Account Sid
$options['accountsid']='0ac771342e5d4a88985e72777b940287';
//填写在开发者控制台首页上的Auth Token
$options['token']='e1cea586fcfb361167de2264d8693f56';
//初始化 $options必填
/*随机生成6位验证码 复杂方式*/
srand((double)microtime()*1000000);//create a random number feed.
$authnum;
$ychar="0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
$list=explode(",",$ychar);
for($i=0;$i<6;$i++){
$randnum=rand(0,35); // 10+26;
$authnum[$i]=$list[$rand