shopex短信接口修改
shopex短信接口修改,56短信插件目前适用于市场上所有的商城、CMS、手机APP、网站等,无论您的程序是那个版本,您在修改中或调到短信接口中遇到问题可以随时联系我们技术人员,微信QQ:826585910,我们将为您提供免费的技术支持,如果您对代码不懂,可以联系我们技术人员帮您免费接入调试。
接入说明:
1. 确保安装ShopEx可以正常运行
2. 后台-短信-添写56短信网账号和密码
3. 安装完成插件后,登陆您的网站后台清除缓存。
4. 核心文件:plugins\messenger\imtong\messenger.imtong.php 核心代如下
<?php
class messenger_imtong{
var $name = '56短信网'; //名称
var $iconclass="56dxw sms"; //操作区图标
var $name_show = '发短信'; //列表页操作区名称
var $version='$ver'; //版本
var $updateUrl=false; //新版本检查地址
var $isHtml = false; //是否html消息
var $hasTitle = false; //是否有标题
var $maxtitlelength =300; //最多字符
var $maxtime = 300; //发送超时时间 ,单位:秒
var $maxbodylength =300; //最多字符
var $allowMultiTarget=false; //是否允许多目标
var $targetSplit = ','; //多目标分隔符
var $withoutQueue = false;
var $dataname='mobile';
var $server_url='http://jiekou.56dxw.com/sms/webinterface.aspx';
/**
* send
* 必有方法,发送时调用
*
* config参数为getOptions取得的所有项的配置结果
*
* @param mixed $to
* @param mixed $message
* @param mixed $config
* @access public
* @return void
*/
function messenger_imtong(){
$this->system = &$GLOBALS['system'];
$this->net=&$this->system->loadModel('utility/http_client');
}
function send($to,$message,$config){
$result=$this->send_info($to,$message,$config);
$msg=$this->msg($result);
return $msg;
}
function send_info($to,$message,$config){
$params = array(
'account'=>$config['username'],
'password'=>$config['password'],
'mobile'=>$to,
'content'=>$message
);
$results = $this->net->post($this->server_url,$params);
if (empty($results))
{
return -1;
}
$xml = $this->xml_to_array($results);
return $xml['SubmitResult']['code'];
}
function msg($index){
$aMsg=array(
"1" => "短信发送成功",
"-21" => "需要加签名",
"-22" => "非法ip访问",
"-2" => "账号或密码错误"
);
return $aMsg[$index];
}
/**
* ready
* 可选方法,准备发送时触发
*
* @param mixed $config
* @access public
* @return void
*/
function ready($config){
}
/**
* ready
* 将 xml数据转换为数组格式。
*
* @param mixed $config
* @access public
* @return void
*/
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;
}
/**
* finish
* 可选方法,结束发送时触发
*
* @param mixed $config
* @access public
* @return void
*/
function finish($config){
}
function getOptions(){
return array(
'username'=>array('label'=>'56短信网apiid','type'=>'input','value'=>''),
'password'=>array('label'=>'56短信网apikey','type'=>'password','value'=>'')
);
}
}
?>