大商创,是一款功能强大的B2B2C多用户商城系统,二次开发进行功能扩展很方便,最近有个客户找到我们想要替换原来的短信接口,因为原来的短信接口不稳定,我们短信宝的短信接口既稳定,又快速。接收验证码短信,通知类的短信,速度真的杠杠滴,推荐大家尝试一下。
第一步:我们需要替换一些配置文件,打开项目/languages/zh_cn/admin/common.php文件,修改代码在350行左右,代码如下:
| 
						1 | $_LANG['huyi_configure'] = '短信宝短信配置'; | 
打开项目/languages/zh_cn/admin/shop_config.php文件,修改代码在53以及129,130左右,修改代码如下:
| 
						1 
						2 
						3 | $_LANG['cfg_range']['sms_type']['0'] = '短信宝';$_LANG['cfg_name']['sms_ecmoban_user'] = '短信宝用户名';$_LANG['cfg_name']['sms_ecmoban_password'] = '短信宝密码'; | 
配置文件修改成功后 我们需要修改一下发送短信的业务代码,修改项目/includes/cls_sms.php文件中的sms和send这两个方法,修改代码如下:
| 
						1 
						2 
						3 
						4 
						5 
						6 
						7 
						8 
						9 
						10 
						11 
						12 
						13 
						14 
						15 
						16 
						17 
						18 
						19 
						20 
						21 
						22 
						23 
						24 
						25 
						26 
						27 
						28 
						29 
						30 
						31 
						32 
						33 
						34 
						35 
						36 
						37 
						38 
						39 
						40 
						41 
						42 
						43 
						44 
						45 
						46 
						47 
						48 
						49 
						50 
						51 
						52 
						53 
						54 
						55 
						56 
						57 
						58 
						59 
						60 
						61 
						62 
						63 
						64 
						65 
						66 
						67 
						68 
						69 
						70 
						71 
						72 
						73 
						74 
						75 
						76 
						77 
						78 
						79 
						80 
						81 
						82 
						83 
						84 
						85 
						86 
						87 
						88 
						89 
						90 | publicfunctionsms()    { $this->sms_name = $GLOBALS['_CFG']['sms_ecmoban_user'];        $this->sms_password = $GLOBALS['_CFG']['sms_ecmoban_password'];        $this->sms_sign = $GLOBALS['_CFG']['shop_name'];    } publicfunctionsend($phones, $msg= '', $send_date= '', $send_num= 1, $sms_type= '', $version= '1.0', &$sms_error= '', $mobile_code= '')    {        if($GLOBALS['_CFG']['sms_type'] == 0) {            $contents= $this->get_contents($phones, $msg);            if(!$contents) {                returnfalse;            }            if(1 < count($contents)) {                foreach($contentsas$key=> $val) {                    $post_data= 'u='. $this->sms_name . '&p='. $this->sms_password . '&m='. $val['phones'] . '&c=【'.$this->sms_sign.'】'. rawurlencode($val['content']);                    $get= file_get_contents($sms_url.$post_data);                    $gets['code']=$get;                    $gets['msg']='发送成功';                    // $get = $this->Post($post_data, $sms_url);                    // $gets = $this->xml_to_array($get);                    sleep(1);                }            }            else{                $post_data= 'u='. $this->sms_name . '&p='. $this->sms_password . '&m='. $contents[0]['phones'] . '&c=【'.$this->sms_sign.'】'. rawurlencode($contents[0]['content']);                $get= file_get_contents($sms_url.$post_data);                $gets['code'] = $get;                $gets['msg'] = '发送成功';                // $get = $this->Post($post_data, $sms_url);                // $gets = $this->xml_to_array($get);            }            if($get== '0') {                returntrue;            }            else{                $statusStr= array(                    "0"=> "短信发送成功",                    "-1"=> "参数不全",                    "-2"=> "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!",                    "30"=> "密码错误",                    "40"=> "账号不存在",                    "41"=> "余额不足",                    "42"=> "帐户已过期",                    "43"=> "IP地址限制",                    "50"=> "内容含有敏感词"                    );                $sms_error= $phones.$statusStr["$get"];                $this->logResult($sms_error);                returnfalse;            }        }        elseif($GLOBALS['_CFG']['sms_type'] == 1) {            $msg= $this->get_usser_sms_msg($msg);            if(!empty($msg['sms_value'])) {                $smsParams= array('mobile_phone'=> $phones, 'code'=> $msg['code']);                $send_time= $msg['sms_value'];            }            else{                $smsParams= array('mobile_phone'=> $phones, 'code'=> $msg['code'], 'product'=> $msg['product']);                $send_time= 'sms_signin';            }            $result= sms_ali($smsParams, $send_time);            $resp= $GLOBALS['ecs']->ali_yu($result);            if($resp->code == 0) {                returntrue;            }            else{                if($resp->sub_msg) {                    $sms_error= $phones. $resp->sub_msg;                }                else{                    $sms_error= $phones. ':'. $resp->msg;                }                $this->logResult($sms_error);                returnfalse;            }        }    } | 
最后我们修改模版文件,项目/admin/templates/website.dwt文件,修改代码在13行左右,代码如下:
| 
						1 |  <li{if $menu_select.current eq 'huyi_configure'}class="curr"{/if}><ahref="huyi_configure.php?act=list">短信宝短信配置</a></li> | 
好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。下面进行测试发送。

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
最新更新
电商类
CMS类
微信类