待发短信

在线客服
产品支持 短信宝客服
合作渠道 渠道合作
服务咨询

4001-021-502

工作时间

9:00-21:00

江湖家政短信接口替换

江湖上门家政服务O2O系统基于LBS定位服务,它是一款通过互联网、通讯技术与传统家政行业结合的新模式,提高家政行业在业务销售、客户管理、信息匹配、市场推广等方面的效率,从而提升整个行业的服务质量和水平提升的软件,他是php源码开发支持二次开发,小编对于这款软件还是比较了解的,今天就为大家分享一下如何进行二次开发,我以替换短信接口为例,一步步为大家讲解如何进行二次开发,使用的接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用。

进行短信接口替换,首先我们需要替换后台的显示页面,打开项目/system/admin/view/config/sms.html,修改12~32行左右,替换代码如下:

?
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
<div class="page-data">
    <h4 class="tip-notice">如有疑问,请咨询短信宝<a href="http://wpa.b.qq.com/cgi/wpa.php?ln=1&key=XzkzODA0NjAyMV8yNTU0MzFfNDAwMDA5MDQ2NV8yXw" target="_blank">客服</a> </h4>
    <form action="?system/config-sms.html" mini-form="config-form" method="post" >
          <input type="hidden" name="K" value="sms" />
          <table width="100%" border="0" cellspacing="0" class="table-data form">
              <tr>
                  <th>显示错误提示:</th>
                  <td>
                    <label><input type="radio" name="config[show_error]" <{if $config.show_error}>checked="checked"<{/if}> value="1"/>开启</label>&nbsp;&nbsp;
                    <label><input type="radio" name="config[show_error]" <{if empty($config.show_error)}>checked="checked"<{/if}> value="0"/>关闭</label>
                    <span class="tip-comment">当短息发送失败时,是否显示相应的提示,建议在调试时打开</span>
                  </td>
              </tr>
              <tr>
                  <th>短信宝帐号:</th>
                  <td>
                      <input type="text" name="config[uname]" value="<{$config.uname|default:''}>" class="input w-200"/>没有短信宝账号?点击<a href="https://www.smsbao.com" target="_blank">免费注册</a>
                  </td>
              </tr>
              <tr>
                  <th>短信宝密码:</th>
                  <td>
                      <input type="password" name="config[passwd]" value="<{$config.passwd|default:''}>" class="input w-200"/>
                  </td>
              </tr>
              <tr>
                  <th>管理员手机:</th>
                  <td>
                      <input type="text" name="config[mobile]" value="<{$config.mobile|default:''}>" class="input w-200"/>
                      <span class="tip-comment">用于接收网站通知,多个手机号用英文,隔开</span>
                  </td>
              </tr>
              <tr>
                  <th class="clear-th-bottom"></th>
                  <td class="clear-td-bottom" colspan="10">
                      <input type="submit" class="bt-big" value="提交数据" />
                  </td>
              </tr>
          </table>
    </form>
</div>

接下来修改发送调用方法,打开项目/home/controller/mobile/passport.ctl.php文件,修改sendsms方法,代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public function sendsms()
{
    if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){
        $phone $this->GP('mobile');
 
        if(!$a = K::M('verify/check')->mobile($phone)){
            $this->err->add('电话号码有误', 212);
        }else{
            $code = rand(100000,999999);
            $session =K::M('system/session')->start();
            $session->set('code_'.$phone$code,900); //15分钟缓存
            $smsdata =  array('code'=>$code);
            if(K::M('sms/smsbao')->send($phone$smsdata)){
                $this->err->add('信息发送成功');
            }else{
                $this->err->add('信息发送失败'.$code, 213);
            }
        }
     }else{
         $this->error(404);
     }
}

后台显示页面修改完成后我们需要修改短信接口的配置文件,打开项目/system/schemas/config/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
<?php
/**
 * Copy Right 99AIJIA.COM
 * Each engineer has a duty to keep the code elegant
 * Author @shzhrui<Anhuike@gmail.com>
 * $Id: sms.php 9343 2015-03-24 07:07:00Z youyi $
 */
 
if(!defined('__CORE_DIR')){
    exit("Access Denied");
}
 
return array (
  'uname' => 
  array (
    'label' => '帐号',
    'field' => 'uname',
    'type' => 'text',
    'default' => '',
    'comment' => '',
    'html' => false,
    'empty' => false,
  ),
  'passwd' => 
  array (
    'label' => '密码',
    'field' => 'passwd',
    'type' => 'text',
    'default' => '',
    'comment' => '',
    'html' => false,
    'empty' => false,
  ),
    'mobile' => 
  array (
    'label' => '管理员接受短信的账号',
    'field' => 'mobile',
    'type' => 'text',
    'default' => '',
    'comment' => '',
    'html' => false,
    'empty' => false,
  ),
);

修改完成后我们修改,接口的发送代码,打开项目/sysytem/models/sms/smsbao.mdl.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
<?php
 
Import::I('sms');
class Mdl_Sms_smsbao implements Sms_Interface
{
 
    protected $_cfg array();
 
    public $lastmsg '';
    public $lastcode = 1;
 
     public function __construct($system)
    {
        $this->_sms = $system->config->get('sms');
        $this->_cfg = K::$system->config->get('site');
        $this->_sitetitle = $this->_cfg['title'];
        $this->_sitephone = $this->_cfg['phone'];
    }
 
    public function send($mobile,$code)
    {
        if ($this->_sms['show_error'] == 0) {
            return false;
        }else{
        $contents '【'.$this->_sitetitle.'】您的验证码为:code,该验证码3分钟有效。';
 
        foreach ($code as $key => $value) {
 
        $content str_replace($key$value$contents);
        }
 
        $url 'http://api.smsbao.com/sms?u='.$this->_sms['uname'].'&p='.md5($this->_sms['passwd']).'&m='.$mobile.'&c='.$content;
        $ret file_get_contents($url);
            if ($ret == 0) {
             K::M('sms/log')->create(array('mobile'=>$mobile'content'=>$content'sms'=>'smsbao''status'=>1));
                return true;
            }else{
             K::M('sms/log')->create(array('mobile'=>$mobile'content'=>$content'sms'=>'smsbao''status'=>0));
                return false;
            }
 
 
        }
    }
}

好了,经过以上的替换,短信宝的短信平台已经替换成功了,可以正常使用了。我们进行测试发送。

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,并且免审核了,短信内容3~5秒就可送达。
开源插件

最新更新

电商类

CMS类

微信类

文章标签