UQCMS短信插件修改,56短信插件目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
接入说明:
1.后台-设置-接口-短信通知- 填写相应的56短信网的账号和密码
2.后台-设置-接口-短信通知,编辑模版,保存点击完成
3.核心文件:\UQframework\class\api 新增加sms_dxw.class.php 文件,代码如下
class sms_dxw {
private $dateTimeFormat = 'Y-m-d\TH:i:s\Z';
function __construct($app_id, $app_key){
$this->app_id = $app_id;
$this->app_key = $app_key;
$this->url = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
}
function send($mobile, $param_arr, $tpl_content, $sign){
foreach ($param_arr as $key=>$vo) {
$tpl_content = str_replace('${' . $key . '}', $param_arr[$key], $tpl_content);
}
$post_data = "account=".$this->app_id."&password=".$this->app_key."&mobile=".$mobile."&content=".rawurlencode($tpl_content);
$gets = $this->xml_to_array($this->Post($post_data, $this->url));
if($gets['SubmitResult']['code']==1){
$result_info['error'] = '0';
$result_info['msg'] = '发送成功';
return $result_info;
}else{
$result_info['error'] = '1';
$result_info['msg'] = $gets['SubmitResult']['msg'];
return $result_info;
}
}
//请求数据到短信接口,检查环境是否 开启 curl init。
function Post($curlPost,$url){
$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;
}
//将 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;
}
}