待发短信

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

4001-021-502

工作时间

9:00-21:00

phpyun7.0新增短信宝短信接口

phpyun人才系统在招聘人才系统中也是佼佼者,最近小编知道了php云人才系统更新到7.0版本了,之前的短信插件也无法使用了,小编也整理了一下,下面带着大家一起进行新版本的替换。我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信平台十分稳定,发送速度快,注册就送测试短信,推荐大家使用。
1:打开项目:app\template\admin\tool\message\component\messageshow.vue 修改35行左右 新增短信宝相关配置

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
<tr>
                  <td>
                     <div class="TableTite">短信宝账号</div>
                  </td>
                  <td>
                     <div class="TableInpt">
                        <el-input placeholder="请输入短信宝账号" v-model="sy_msg_appkey"></el-input>
                     </div>
                  </td>
                  <td>
                     <div class="TableShuom">
         <span><a href="https://console.smsbao.com/#/register" target="_blank" style="color: red;white-space: nowrap;">还没有短信宝账号?点击注册</a>
</span>
                     </div>
                  </td>
               </tr>
<tr>
   <td>
      <div class="TableTite">短信宝密码</div>
   </td>
   <td>
      <div class="TableInpt">
         <el-input placeholder="请输入短信宝密码" v-model="sy_msg_appsecret"></el-input>
      </div>
   </td>
   <td>
      <div class="TableShuom">
         <span> </span>
      </div>
   </td>
</tr>
<tr>
   <td>
      <div class="TableTite">单IP每日最大发送</div>
   </td>
   <td>
      <div class="TableInpt">
         <el-input placeholder="请输入内容" v-model="ip_msgnum" @input="inputIntNumber($event, 'ip_msgnum')">
            <template slot="append">条</template>
         </el-input>
      </div>
   </td>
   <td>
      <div class="TableShuom">
         <span> </span>
      </div>
   </td>
</tr>

2:打开项目:admin\model\tool\messageset.class.php 增加查询短信接口 大概第8行

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
    function index_action(){
         
        $msgnum = $businessnum = $khnum = 0;
 
        if (!empty($this->config['sy_msg_appkey']) && !empty($this->config['sy_msg_appsecret'])) {
 
            //短信检测
            $url = 'https://www.smsbao.com/query';
            $url .= '?u=' . $this->config['sy_msg_appkey'] . '&p=' . md5($this->config['sy_msg_appsecret']);
            if (extension_loaded('curl')) {
                $return = CurlGet($url);
            else if (function_exists('file_get_contents')) {
                $return = file_get_contents($url);
            }
            if ($return) {
                $msgInfo = explode(',', $return);
                if (is_array($msgInfo)){
                    $msgnum = $msgInfo[1];
                }
                unset($return);
            }
        }
 
        if (!empty($this->config['sy_kh_appkey']) && !empty($this->config['sy_kh_appsecret'])) {
            //空号检测
            $url = 'https://u.phpyun.com/feature';
            $url .= '?appKey=' . $this->config['sy_kh_appkey'] . '&appSecret=' . $this->config['sy_kh_appsecret'];
            if (extension_loaded('curl')) {
 
                $return = CurlGet($url);
            else if (function_exists('file_get_contents')) {
 
                $return = file_get_contents($url);
            }
            if ($return) {
                $msgInfo = json_decode($returntrue);
                if ($msgInfo['code'] == '200') {
                    $khnum = $msgInfo['num'];
                }
                unset($return);
            }
        }
 
        if (!empty($this->config['sy_tyc_appkey']) && !empty($this->config['sy_tyc_appsecret'])) {
            //天眼查检测
            $url = 'https://u.phpyun.com/feature';
            $url .= '?appKey=' . $this->config['sy_tyc_appkey'] . '&appSecret=' . $this->config['sy_tyc_appsecret'];
 
            if (extension_loaded('curl')) {
 
                $return = CurlGet($url);
            else if (function_exists('file_get_contents')) {
 
                $return = file_get_contents($url);
            }
            if ($return) {
                $msgInfo = json_decode($returntrue);
                if ($msgInfo['code'] == '200') {
                    $businessnum = $msgInfo['num'];
                }
            }
        }
 
        $data = array(
            'sy_msg_isopen'     =>  $this->config['sy_msg_isopen'],
            'sy_msg_appkey'     =>  $this->config['sy_msg_appkey'],
            'sy_msg_appsecret'  =>  $this->config['sy_msg_appsecret'],
            'ip_msgnum'         =>  $this->config['ip_msgnum'],
            'moblie_msgnum'     =>  $this->config['moblie_msgnum'],
            'cert_msgtime'      =>  $this->config['cert_msgtime'],
            'moblie_codetime'   =>  $this->config['moblie_codetime'],
            'sy_kh_isopen'      =>  $this->config['sy_kh_isopen'],
            'sy_kh_appkey'      =>  $this->config['sy_kh_appkey'],
            'sy_kh_appsecret'   =>  $this->config['sy_kh_appsecret'],
            'sy_kh_city'        =>  $this->config['sy_kh_city'],
            'sy_tyc_appkey'     =>  $this->config['sy_tyc_appkey'],
            'sy_tyc_appsecret'  =>  $this->config['sy_tyc_appsecret'],
 
            'rest_msgnum'            =>  $msgnum,
            'rest_businessnum'       =>  $businessnum,
            'rest_khnum'             =>  $khnum,
        );
         
        $this->render_json(0,'ok', $data);
    }

3:打开项目:app\model\notice.model.php 修改短信发送函数 大概260行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
   function postSMS($type='msgsend',$data=''){
       $sign = $this->config['sy_webname'];
       $data['content'] = str_replace(array(" "," ","\t","\n","\r"),array("","","","",""),$data['content']);
       $url='http://api.smsbao.com/sms';
       $url.='?u='.$data['appkey'].'&p='.md5($data['appsecret']).'&m='.$data['phone'].'&c='.'【'.$sign.'】'.$data['content'];
if (extension_loaded('curl')){
           $file_contents = CurlGet($url);
       }else if(function_exists('file_get_contents')){
           $file_contents = file_get_contents($url);
       }
       return [
           'code'=>$file_contents === '0' ? 200 : 501,
           'message'=>$file_contents === '0' ?  '发送成功' '发送失败'
       ];
   }

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

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。

另外:我们已经开发好完整的phpyun7.0系统短信宝插件,点击此链接 下载及查看安装流

开源插件

最新更新

电商类

CMS类

微信类

文章标签