得推校园O2O修改,56短信接口目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ同号:QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
1.基本设置-短信设置,填写你的56短信网的用户名和密码
2.打开\source\admin\config.ctrl.php 核心代码如下:
public function configfile()
{
$rs=M("config")->selectRow();
unset($rs['siteid']);
unset($rs['id']);
$str='<?php'."\r\n";
foreach($rs as $key=>$val)
{
$str.='define("'.strtoupper($key).'",'."\"{$val}\");\r\n";
}
$str.='?>';
file_put_contents(ROOT_PATH."/config/setconfig.php",$str);
}
public function onTestPhone(){
//生成的随机数
$mobile_code = rand(100000,999999);
$content="您的验证码是:".$mobile_code."。请不要把验证码泄露给其他人。";
$target = "http://jiekou.56dxw.com/sms/webinterface.aspx";
$post_data = "username=".get_post('phone_user')."&userpwd=".get_post('phone_pwd')."&handtel=".get_post('phone_num')."&sendcontent=".rawurlencode($content);
//用户名请登录用户中心->验证码、通知短信->帐户及签名设置->APIID
//查看密码请登录用户中心->验证码、通知短信->帐户及签名设置->APIKEY
$gets = xml_to_array(posts($post_data, $target));
if($gets['SubmitResult']['code'] == 2){
echo "发送成功,请接收短信!";
}else{
echo "发送失败".$res;
}
}