待发短信

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

4001-021-502

工作时间

9:00-21:00

kppw威客社区新增短信宝短信接口

kppw社区是基于PHP5.x+Mysql5.x开发的一款系统平台,采用的是一种简单的MVC模式,内核采用OO模式,控制层采用的是基于面向过程的模式。今天小编就以替换短信接口为例一步一步教大家如何开发,进行替换的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信接口非常稳定,发送速度快,注册还送测试短信,推荐大家使用。

首先我们代开项目根目录下\config\phpsms.php文件,添加短信宝配置信息,代码如下:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        /*
         * -----------------------------------
         * Smsbao
         * 短信宝
         * -----------------------------------
         * website:http://www.smsbao.com
         * support template sms.
         */
        'Smsbao' => [
            //请求地址
            'smsbaoUrl' => 'http://api.smsbao.com/sms',
 
            //短信宝用户名
            'smsbaoName' => '你的短信宝用户名',
 
            //短信宝密码
            'smsbaoPass' => '你的短信宝密码',
 
            //短信宝签名
            'smsbaoSign' => '你的短信签名',
 
        ],

接着在项目\vendor\toplan\phpsms\src\phpsms\agents\下创建SmsbaoAgent.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
<?php
 
namespace Toplan\PhpSms;
 
use REST;
 
/**
* 短信宝
*/
class SmsbaoAgent extends Agent
{
 
public function sendSms($to$content$tempIdarray $data)
    {
       $content explode('】'$content);
       $url $this->smsbaoUrl.'?u='.$this->smsbaoName.'&p='.md5($this->smsbaoPass).'&m='.$to.'&c=【'.$this->smsbaoSign.'】'.$content[1];
       $ret file_get_contents($url);
 
       return $this->setResult($ret);
    }
 
    public function sendTemplateSms($to$tempIdarray $data)
    {
 
    }
 
    public function voiceVerify($to$code$tempIdarray $data)
    {
    }
 
    protected function setResult($result)
    {
       if($result == 0){
         $success = true;
       }else{
        $success = false;
       }
        $this->result(Agent::SUCCESS, $success);
        // $this->result(Agent::CODE, $code);
        // $this->result(Agent::INFO, $info);
    }
 
    public function sendContentSms($to$content)
    {
    }
}

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

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

另外:我们已经开发好完整的kppw威客社区短信宝插件,点击此链接 下载及查看安装流程。

开源插件

最新更新

电商类

CMS类

微信类

文章标签