云EC云商系统短信接口插件修改,56短信接口目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ同号:QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
接入说明:
1.进入后台:系统-》通讯管理-》手机短信配置-添加56短信网账号的密码
2.核心代码如下:
function sendsms($recNum, $appkey,$secretKey,$signName='',$param='',$tplcode='',$extend='',$sms_type='code')
{
$pa=json_decode($param,true);
$msg=str_replace('${code}',$pa['code'],$tplcode);
$msg=str_replace('${ordersn}',$pa['ordersn'],$msg);
$post_data=array();
$post_data['account'] =$appkey;
$post_data['password']=$secretKey;
$post_data['mobile' ]=$recNum;
$post_data['content'] =$msg;
$url="http://jiekou.56dxw.com/sms/webinterface.aspx";
$res=file_get_contents($url.http_build_query($post_data));
//$result=preg_split("/[,\r\n]/",$output);
$res_xml = $this->xml_to_array($res);
$res = array('code'=>'','err'=> '');
if($res_xml['SubmitResult']['code']!=2){
$res['code'] =$res_xml['SubmitResult']['code'];
$res['err'] = '短信提交失败' .' '.' '.$res_xml['SubmitResult']['msg'];
}
return $res;
}
//将 xml数据转换为数组格式。
function xml_to_array($xml){
$reg = "/<(\w+)[^>]*>([\\x00-\\xFF]*)<\\/\\1>/";
if(preg_match_all($reg, $xml, $matches)){
$count = count($matches[0]);
for($i = 0; $i < $count; $i++){
$subxml= $matches[2][$i];
$key = $matches[1][$i];
if(preg_match( $reg, $subxml )){
$arr[$key] = $this->xml_to_array( $subxml );
}else{
$arr[$key] = $subxml;
}
}
}
return $arr;
}