SDK调用阿里大鱼短信API成功发送验证码并实现验证功能
随风飘扬 学习 2016年01月26日6:58 3776
淘宝:不下SDK就想那么容易用我的API?真是too young,too simple 在TO
淘宝:不下SDK就想那么容易用我的API?真是too young,too simple
在TOP创建APP后将对应的SDK下载后上传至网站空间,然后在同一目录下新建一个PHP,代码如下,只涉及到验证短信发送和短信验证码存储。。验证模块代码省略
$c = new TopClient;
$time=date("Y-m-d H:i:s");
$phone=htmlentities($_GET["phone"]);
$code=strtoupper(substr(MD5($phone.time().rand()),rand(1,25),4));//生成验证码
$c->appkey = 'APP_KEY';//你的APP_KEY
$c->secretKey = 'APP_SECRET';//你的APP_SECRET
$req = new AlibabaAliqinFcSmsNumSendRequest;
$req->setSmsType("normal");
$req->setSmsFreeSignName("注册验证");//签名
$req->setSmsParam('{"code":"'.$code.'","product":"Ta技"}');//传入参数,需与短信模版内参数一致
$req->setRecNum($phone);
$req->setSmsTemplateCode("SMS_*******");短信模板
$resp = $c->execute($req);
$insert_query = mysql_query("insert into sms values('','$phone','$code','$time')");//存储验证码
Statement: all articles / drawings reproduced on this website are for the purpose of transmitting more information and facilitating discussion, which does not mean that the website, the host and the organizer agree with their opinions or confirm the authenticity of their contents. The contents of the articles are for reference only. If the rights of the original author are violated, please contact the website administrator.
Comment list
-
No data