DSMALL系统是基于THinkPHP开发的一款开源的B2B2C电子商务系统,因为是THinkPHP开发所以二次开发比较方便,小编对于这套程序还是比较了解的,今天小编就以替换短信接口为例,为大家讲解一下如何进行二次开发,我们今天讲解的是20171202版本,使用的短信接口是我们短信宝短信群发平台的接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。
第一步,我们去替换后台显示界面,打开项目\application\admin\view\message\mobile.html文件,替换为以下代码:
| 
						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 | {include file="public/header" /}<divid="append_parent"></div><divid="ajaxwaitid"></div><divclass="page">    <divclass="fixed-bar">        <divclass="item-title">            <divclass="subject">                <h3>邮箱短信</h3>                <h5></h5>            </div>            {include file="public/admin_items" /}        </div>    </div>    <formmethod="post">        <divclass="ncap-form-default">            <dl>                <dt>短信宝用户名</dt>                <dd>                    <inputtype="text"name="mobile_username"id="mobile_username"value="{$list_config.mobile_username}"class="w200"/>                </dd>            </dl>                        <dl>                <dt>短信宝密码</dt>                <dd>                    <inputtype="text"name="mobile_pwd"id="mobile_pwd"value="{$list_config.mobile_pwd}"class="w200"/>                </dd>            </dl>            <dl>                <dt>短信签名</dt>                <dd>                    <inputtype="text"name="mobile_signature"id="mobile_signature"value="{$list_config.mobile_signature}"class="w200"/>                </dd>            </dl>            <dl>                <dt></dt>                <dd>                    <inputclass="btn"type="submit"value="提交"/>                </dd>            </dl>                    </div>    </form>    </div> | 
第二步,我们去修改短信接口类,打开项目\extend\sendmsg\Sms.php文件,替换为以下代码:
| 
						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 | <?php/** * 手机短信类 */namespacesendmsg;classSms{    /*     * 发送手机短信     * @param unknown $mobile 手机号     * @param unknown $content 短信内容    */    publicfunctionsend($mobile, $content)    {           return$this->mysend_sms($mobile, $content);    }    privatefunctionmysend_sms($mobile, $content)    {        $user_id= urlencode(config('mobile_username'));         $mobile_pwd= urlencode(config('mobile_pwd'));         $sign= urlencode(config('mobile_signature'));        if(!$mobile|| !$content|| !$user_id|| !$mobile_pwd)            returnfalse;        if(is_array($mobile)) {            $mobile= implode(",", $mobile);        }        $mobile=urlencode($mobile);        $content=urlencode($content);        $url= 'http://api.smsbao.com/sms?u='.$user_id.'&p='.md5($mobile_pwd).'&m='.$mobile.'&c=【'.$sign.'】'.$content;        if(function_exists('file_get_contents')) {            $res= file_get_contents($url);        }        else{            $ch= curl_init();            $timeout= 5;            curl_setopt($ch, CURLOPT_URL, $url);            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);            $res= curl_exec($ch);            curl_close($ch);        }        if($res== 0) {            returntrue;        }        returnfalse;    }} | 
	好了,经过以上的替换,短信宝的短信平台已经替换成功了,我们去进行发送测试:
	
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
最新更新
电商类
CMS类
微信类