OURSHOP建站系统短信接口修改,56短信接口目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ同号:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
接入说明:
1.管理后台->全局->API接口管理->添加如下,56短信短信接口|1|56短信接口apiid|56短信接口apikey
2.进入后台->用户->开启注册,用手机号做账号,注册验证码开启,开启登陆等。
<?php
class ourphpsms{
public function smsconfig($m='',$c='',$s='',$t=1){
global $db;
$rs = $db -> select("OP_Key","`ourphp_api`"," where OP_Key LIKE '%56短信网%'");
$rs = explode('|',$rs[0]);
if($rs[1] == 2){
return false;
}else{
$http = 'http://jiekou.56dxw.com/sms/webinterface.aspx';
$uid = $rs[2];
$pwd = $rs[3];
$mobile = $m;
$mobileids = '';
$content = $c;
return $this->sendSMS($http,$uid,$pwd,$mobile,$content,$mobileids,$sign);
}
}
function sendSMS($http,$uid,$pwd,$mobile,$content,$mobileids,$time='',$mid=''){
$data = array
(
'account'=>$uid, //56短信网无线apiid
'password'=>$pwd, //56短信网无线apikey
'mobile'=>$mobile, //手机号码
'content'=>$content, //发送内容
);
return $this->postSMS($http,$data); //POST方式提交
}
function postSMS($url,$data=''){
$port="";
$post="";
$row = parse_url($url);
$host = $row['host'];
@$port = $row['port'] ? $row['port']:80;
$file = $row['path'];
while (list($k,$v) = each($data))
{
$post .= rawurlencode($k)."=".rawurlencode($v)."&"; //转URL标准码
}
$sendsms = $this->Post($data,$url);
$sendarray = $this->xml_to_array($sendsms);
if($sendarray['SubmitResult']['code'] == '2'){
return "";
}else{
return $sendarray['SubmitResult']['msg'];
}
}
//请求数据到短信接口,检查环境是否 开启 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;
}
}
$smskey = new ourphpsms();
?>