最近做了个发送短信验证码这个功能,自己搞了一个短信平台的方案对比,虽然做的不是很好,但是 也了解方案对比的一些事情。而且也对发送验证码有了一定的了解。
最后选了微米短信平台,使用方法如下:
//发送短信 微米
function shortMessage($mob,$code){
$url='http://api.weimi.cc/2/sms/send.html';
$uid='****';
$pas='****';
$con="【签名】您的验证码是:".$code."。请不要把验证码泄露给其他人。";
$type='json'; //返回数据格式
$cid='***'; //短息模板的cid
$p2='3'; //设置验证码在3分钟内有效
$data2 = "uid=".$uid."&pas=".$pas."&mob=".$mob."&con=".$con."&type=".$type."&cid=".$cid."&p1=".$code."&p2=".$p2;
return postCurl($url,$data2);
}
function postCurl($url,$curlPost){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curlPost);
$return_str = curl_exec($curl);
curl_close($curl);
return $return_str;
}
shortMessage('手机号','验证码');
短信平台方案对比文档下载:
http://download.youkuaiyun.com/detail/u011362846/9572637