MobileCodeDemoPlugin.php
2.0 KB
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
<?php
// +----------------------------------------------------------------------
// | bronet [ 以客户为中心 以奋斗者为本 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2017 http://www.bronet.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: Dean <zxxjjforever@163.com>
// +----------------------------------------------------------------------
namespace plugins\mobile_code_demo;//Demo插件英文名,改成你的插件英文就行了
use cmf\lib\Plugin;
/**
* MobileCodeDemoPlugin
*/
class MobileCodeDemoPlugin extends Plugin
{
public $info = [
'name' => 'MobileCodeDemo',
'title' => '手机验证码演示插件',
'description' => '手机验证码演示插件',
'status' => 1,
'author' => 'bronet',
'version' => '1.0'
];
public $has_admin = 0;//插件是否有后台管理界面
public function install() //安装方法必须实现
{
return true;//安装成功返回true,失败false
}
public function uninstall() //卸载方法必须实现
{
return true;//卸载成功返回true,失败false
}
//实现的send_mobile_verification_code钩子方法
public function sendMobileVerificationCode($param)
{
$mobile = $param['mobile'];//手机号
$code = $param['code'];//验证码
$config = $this->getConfig();
$expire_minute = intval($config['expire_minute']);
$expire_minute = empty($expire_minute) ? 30 : $expire_minute;
$expire_time = time() + $expire_minute * 60;
$result = false;
// $result = [
// 'error' => 1,
// 'message' => '服务商返回结果错误'
// ];
$result = [
'error' => 0,
'message' => '演示插件,您的验证码是'.$code
];
return $result;
}
}