phpok5.4是一套针对网站建设的内容管理系统,采用 PHP 语言编写,默认使用 MySQL 数据库存储,基于 LGPL 开源协议授权发布到网上共享使用。这是一套开源的,免费的企业网站程序!二次开发比较简单,小编对这它还是比较了解的,今天小编就以新增短信接口为例,带大家进行二次开发。使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用!
打开项目:gateway\sms 新建smsbao 文件夹,在smsbao文件夹下创建一个sendsms.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
|
<?phpif(!defined("PHPOK_SET")){exit("<h1>Access Denied</h1>");}$update = $this->get('update');if($update){ $mobile = $this->get('mobile'); if(!$mobile){ $this->error('未指定手机号'); } if(!$this->lib('common')->tel_check($mobile,'mobile')){ $this->error('手机号格式不正式'); } $content = $this->get('content'); if(!$content){ $this->error('未指定要发送的内容'); } if (empty($rs['ext']['smsbao_user']) || empty($rs['ext']['smsbao_pass']) || empty($rs['ext']['smsbao_sign'])) { $this->error('请填写短信宝用户名、密码和签名'); } $url = 'http://api.smsbao.com/sms?u='.$rs['ext']['smsbao_user'].'&p='.md5($rs['ext']['smsbao_pass']).'&m='.$mobile.'&c=【'.$rs['ext']['smsbao_sign'].'】'.$content; $ret = file_get_contents($url); if($ret == 0){ $this->success('短信发送成功'); return true; } $this->error($info['message']); return false;}$this->view($this->dir_root.'gateway/'.$rs['type'].'/sendsms.html','abs-file'); |
打开项目:gateway\sms\smsbao 在smsbao文件夹下创建一个exec.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
|
<?phpif(!defined("PHPOK_SET")){exit("<h1>Access Denied</h1>");}if (!$rs['ext'] || !$rs['ext']['smsbao_user'] || !$rs['ext']['smsbao_pass'] || !$rs['ext']['smsbao_sign']) { if($this->config['debug']){ phpok_log(P_Lang('短信宝短信参数配置不全')); } return false;} if(!$extinfo['mobile'] || !$extinfo['content']){ if($this->config['debug']){ phpok_log(P_Lang('手机号或短信模版未配置')); } return false;}$url = 'http://api.smsbao.com/sms?u='.$rs['ext']['smsbao_user'].'&p='.md5($rs['ext']['smsbao_pass']).'&m='.$extinfo['mobile'].'&c=【'.$rs['ext']['smsbao_sign'].'】'.$extinfo['content'];$ret = file_get_contents($url);if ($ret == 0) { return true;} else { if($this->config['debug']){ phpok_log($ret); } return false;} |
打开项目:gateway\sms\smsbao 在smsbao文件夹下创建一个config.xml文件
|
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
|
<?xml version="1.0" encoding="utf-8"?><root> <title>短信宝短信</title> <note>官网(http://www.smsbao.com)</note> <code> <smsbao_user> <title>短信宝用户名</title> <note>请输入您在短信宝注册的帐号</note> <type>text</type> <required>true</required> </smsbao_user> <smsbao_pass> <title>短信宝密码</title> <note>请输入短信宝密码</note> <type>text</type> <required>true</required> </smsbao_pass> <smsbao_sign> <title>短信签名</title> <note>请输入短信签名</note> <type>text</type> <required>true</required> </smsbao_sign> <mobile> <title>手机号</title> <note>填写管理员接收短信要用到的手机号,仅支持一个手机号</note> <type>text</type> <required>true</required> </mobile> </code> <manage> <send> <title>发短信</title> <exec>sendsms</exec> <type>page</type> </send> </manage></root> |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:

报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的phpok5.4系统短信宝插件,点击此链接 下载及查看安装流程。
- 上一篇:微擎V_2.0新增短信宝短信接口 下一篇:微擎V_2.1.2新增短信宝短信接口

