正在显示
7 个修改的文件
包含
232 行增加
和
1 行删除
@@ -8,12 +8,14 @@ namespace api\portal\controller; | @@ -8,12 +8,14 @@ namespace api\portal\controller; | ||
8 | 8 | ||
9 | use cmf\controller\RestBaseController; | 9 | use cmf\controller\RestBaseController; |
10 | use think\Db; | 10 | use think\Db; |
11 | + | ||
11 | /** | 12 | /** |
12 | * @title 我的 | 13 | * @title 我的 |
13 | * @description 个人中心相关接口 | 14 | * @description 个人中心相关接口 |
14 | */ | 15 | */ |
15 | class UserController extends RestBaseController | 16 | class UserController extends RestBaseController |
16 | { | 17 | { |
18 | + | ||
17 | /** | 19 | /** |
18 | * @title 我的健康档案 | 20 | * @title 我的健康档案 |
19 | * @description 健康档案页渲染 | 21 | * @description 健康档案页渲染 |
@@ -52,7 +54,40 @@ class UserController extends RestBaseController | @@ -52,7 +54,40 @@ class UserController extends RestBaseController | ||
52 | public function registerPost(){ | 54 | public function registerPost(){ |
53 | $param=$this->request->param(); | 55 | $param=$this->request->param(); |
54 | $param['status']=1; | 56 | $param['status']=1; |
55 | - Db::name('user')->where('id')->update($param); | 57 | + Db::name('user')->where('id',$this->getUserId())->update($param); |
56 | $this->success('提交成功'); | 58 | $this->success('提交成功'); |
57 | } | 59 | } |
60 | + | ||
61 | + /** | ||
62 | + * @title 手机号注册 | ||
63 | + * @description 手机号注册提交接口 | ||
64 | + * @author panhaowen | ||
65 | + * @url /portal/User/mobile | ||
66 | + * @method POST | ||
67 | + * @header name:XX-Token require:1 default: desc:token | ||
68 | + * @param name:mobile require:1 | ||
69 | + */ | ||
70 | + public function mobile(){ | ||
71 | + $param=$this->request->param(); | ||
72 | + Db::name('user')->where('id',$this->getUserId())->update(['mobile'=>$param['mobile']]); | ||
73 | + $this->success('注册提交成功'); | ||
74 | + } | ||
75 | + | ||
76 | + /** | ||
77 | + * @title 获取验证码 | ||
78 | + * @description 获取验证码接口 | ||
79 | + * @author panhaowen | ||
80 | + * @url /portal/User/getCode | ||
81 | + * @method POST | ||
82 | + * @header name:XX-Token require:1 default: desc:token | ||
83 | + * @param name:mobile require:1 | ||
84 | + */ | ||
85 | + public function getCode(){ | ||
86 | + $param=$this->request->param(); | ||
87 | + require_once VENDOR_PATH . "sms/serverSid.php"; | ||
88 | + require_once VENDOR_PATH . "sms/lib/Ucpaas.class.php"; | ||
89 | + $send=new \Ucpaas(); | ||
90 | + $code = cmf_get_verification_code($param['mobile'], 4); | ||
91 | + $send->SendSms('78950d10e37b4ae5bd9b9c08f3720db3','41494',$code,17694933850); | ||
92 | + } | ||
58 | } | 93 | } |
simplewind/vendor/sms/index.html
0 → 100644
1 | +<html> | ||
2 | + <head> | ||
3 | + <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> | ||
4 | + <title>云之讯 - 验证短信测试Demo</title> | ||
5 | + <script type="text/javascript" src="uc/jquery-easyui-1.4.5/jquery.min.js"></script> | ||
6 | + </head> | ||
7 | +<body style="background-color:#48c690"> | ||
8 | +<br> | ||
9 | +<p style="text-align:center"><b>测试短信验证码</b></p> | ||
10 | +<p style="text-align:center;color:#FF0000">测试前,请先阅读《请先读我(重要).doc》并配置好相应参数,<a href="http://docs.ucpaas.com/doku.php?id=error_code" target="black">点击查看错误码</a></p> | ||
11 | + <div style="margin:0 auto;width:350px;height:150px"> | ||
12 | + <form id="myForm" action="smsyzm.php" method="post"> | ||
13 | + <table> | ||
14 | + <tr> | ||
15 | + <td>接收短信的手机号: </td> | ||
16 | + <td><input type="text" name="yzmtel" size="20" style="margin-right:0px"> </td> | ||
17 | + </tr> | ||
18 | + <tr> | ||
19 | + <td>验证码: </td> | ||
20 | + <td><input type="text" name="yzm" size="20" style="margin-right:0px"></td> | ||
21 | + </tr> | ||
22 | + <tr> | ||
23 | + <td><a href="#" onclick="document.getElementById('myForm').submit();"></td> | ||
24 | + <td><input type="submit" value="提交测试" style="margin-left: 0px;width:100px;"/></td> | ||
25 | + </tr> | ||
26 | + </table> | ||
27 | + </form> | ||
28 | + </div> | ||
29 | +</body> | ||
30 | +</html> |
simplewind/vendor/sms/lib/Ucpaas.class.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +/** | ||
4 | + * Created by Notepad++ | ||
5 | + * User: UCPAAS NickLuo | ||
6 | + * Date: 2017/11/09 | ||
7 | + * Time: 08:28 | ||
8 | + * Dec : ucpass php sdk | ||
9 | + */ | ||
10 | +class Ucpaas | ||
11 | +{ | ||
12 | + //API请求地址 | ||
13 | + const BaseUrl = "https://open.ucpaas.com/ol/sms/"; | ||
14 | + | ||
15 | + //开发者账号ID。由32个英文字母和阿拉伯数字组成的开发者账号唯一标识符。 | ||
16 | + private $accountSid; | ||
17 | + | ||
18 | + //开发者账号TOKEN | ||
19 | + private $token; | ||
20 | + | ||
21 | + public function __construct($options) | ||
22 | + { | ||
23 | + if (is_array($options) && !empty($options)) { | ||
24 | + $this->accountSid = isset($options['accountsid']) ? $options['accountsid'] : ''; | ||
25 | + $this->token = isset($options['token']) ? $options['token'] : ''; | ||
26 | + } else { | ||
27 | + throw new Exception("非法参数"); | ||
28 | + } | ||
29 | + } | ||
30 | + | ||
31 | + private function getResult($url, $body = null, $method) | ||
32 | + { | ||
33 | + $data = $this->connection($url,$body,$method); | ||
34 | + if (isset($data) && !empty($data)) { | ||
35 | + $result = $data; | ||
36 | + } else { | ||
37 | + $result = '没有返回数据'; | ||
38 | + } | ||
39 | + return $result; | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * @param $url 请求链接 | ||
44 | + * @param $body post数据 | ||
45 | + * @param $method post或get | ||
46 | + * @return mixed|string | ||
47 | + */ | ||
48 | + | ||
49 | + private function connection($url, $body,$method) | ||
50 | + { | ||
51 | + if (function_exists("curl_init")) { | ||
52 | + $header = array( | ||
53 | + 'Accept:application/json', | ||
54 | + 'Content-Type:application/json;charset=utf-8', | ||
55 | + ); | ||
56 | + $ch = curl_init($url); | ||
57 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
58 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | ||
59 | + if($method == 'post'){ | ||
60 | + curl_setopt($ch,CURLOPT_POST,1); | ||
61 | + curl_setopt($ch,CURLOPT_POSTFIELDS,$body); | ||
62 | + } | ||
63 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
64 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | ||
65 | + $result = curl_exec($ch); | ||
66 | + curl_close($ch); | ||
67 | + } else { | ||
68 | + $opts = array(); | ||
69 | + $opts['http'] = array(); | ||
70 | + $headers = array( | ||
71 | + "method" => strtoupper($method), | ||
72 | + ); | ||
73 | + $headers[]= 'Accept:application/json'; | ||
74 | + $headers['header'] = array(); | ||
75 | + $headers['header'][]= 'Content-Type:application/json;charset=utf-8'; | ||
76 | + | ||
77 | + if(!empty($body)) { | ||
78 | + $headers['header'][]= 'Content-Length:'.strlen($body); | ||
79 | + $headers['content']= $body; | ||
80 | + } | ||
81 | + | ||
82 | + $opts['http'] = $headers; | ||
83 | + $result = file_get_contents($url, false, stream_context_create($opts)); | ||
84 | + } | ||
85 | + return $result; | ||
86 | + } | ||
87 | + | ||
88 | + /** | ||
89 | + 单条发送短信的function,适用于注册/找回密码/认证/操作提醒等单个用户单条短信的发送场景 | ||
90 | + * @param $appid 应用ID | ||
91 | + * @param $mobile 接收短信的手机号码 | ||
92 | + * @param $templateid 短信模板,可在后台短信产品→选择接入的应用→短信模板-模板ID,查看该模板ID | ||
93 | + * @param null $param 变量参数,多个参数使用英文逗号隔开(如:param=“a,b,c”) | ||
94 | + * @param $uid 用于贵司标识短信的参数,按需选填。 | ||
95 | + * @return mixed|string | ||
96 | + * @throws Exception | ||
97 | + */ | ||
98 | + public function SendSms($appid,$templateid,$param=null,$mobile,$uid){ | ||
99 | + $url = self::BaseUrl . 'sendsms'; | ||
100 | + $body_json = array( | ||
101 | + 'sid'=>$this->accountSid, | ||
102 | + 'token'=>$this->token, | ||
103 | + 'appid'=>$appid, | ||
104 | + 'templateid'=>$templateid, | ||
105 | + 'param'=>$param, | ||
106 | + 'mobile'=>$mobile, | ||
107 | + 'uid'=>$uid, | ||
108 | + ); | ||
109 | + $body = json_encode($body_json); | ||
110 | + $data = $this->getResult($url, $body,'post'); | ||
111 | + return $data; | ||
112 | + } | ||
113 | + | ||
114 | + /** | ||
115 | + 群发送短信的function,适用于运营/告警/批量通知等多用户的发送场景 | ||
116 | + * @param $appid 应用ID | ||
117 | + * @param $mobileList 接收短信的手机号码,多个号码将用英文逗号隔开,如“18088888888,15055555555,13100000000” | ||
118 | + * @param $templateid 短信模板,可在后台短信产品→选择接入的应用→短信模板-模板ID,查看该模板ID | ||
119 | + * @param null $param 变量参数,多个参数使用英文逗号隔开(如:param=“a,b,c”) | ||
120 | + * @param $uid 用于贵司标识短信的参数,按需选填。 | ||
121 | + * @return mixed|string | ||
122 | + * @throws Exception | ||
123 | + */ | ||
124 | + public function SendSms_Batch($appid,$templateid,$param=null,$mobileList,$uid){ | ||
125 | + $url = self::BaseUrl . 'sendsms_batch'; | ||
126 | + $body_json = array( | ||
127 | + 'sid'=>$this->accountSid, | ||
128 | + 'token'=>$this->token, | ||
129 | + 'appid'=>$appid, | ||
130 | + 'templateid'=>$templateid, | ||
131 | + 'param'=>$param, | ||
132 | + 'mobile'=>$mobileList, | ||
133 | + 'uid'=>$uid, | ||
134 | + ); | ||
135 | + $body = json_encode($body_json); | ||
136 | + $data = $this->getResult($url, $body,'post'); | ||
137 | + return $data; | ||
138 | + } | ||
139 | +} |
simplewind/vendor/sms/serverSid.php
0 → 100644
1 | +<?php | ||
2 | +//载入ucpass类 | ||
3 | +require_once('lib/Ucpaas.class.php'); | ||
4 | + | ||
5 | +//初始化必填 | ||
6 | +//填写在开发者控制台首页上的Account Sid | ||
7 | +$options['accountsid']='d63e23ab657c95babad1681133dbabdc'; | ||
8 | +//填写在开发者控制台首页上的Auth Token | ||
9 | +$options['token']='1fc7377f48edb5bf1659284210f16418'; | ||
10 | + | ||
11 | +//初始化 $options必填 | ||
12 | +$ucpass = new Ucpaas($options); |
simplewind/vendor/sms/smsyzm.php
0 → 100644
1 | +<?php | ||
2 | +//载入ucpass类 | ||
3 | +require_once('lib/Ucpaas.class.php'); | ||
4 | +require_once('serverSid.php'); | ||
5 | + | ||
6 | + | ||
7 | +$appid = "78950d10e37b4ae5bd9b9c08f3720db3"; //应用的ID,可在开发者控制台内的短信产品下查看 | ||
8 | +$templateid = "41494"; //可在后台短信产品→选择接入的应用→短信模板-模板ID,查看该模板ID | ||
9 | +$param = $_POST['yzm']; //多个参数使用英文逗号隔开(如:param=“a,b,c”),如为参数则留空 | ||
10 | +$mobile = $_POST['yzmtel']; | ||
11 | +$uid = ""; | ||
12 | + | ||
13 | +//70字内(含70字)计一条,超过70字,按67字/条计费,超过长度短信平台将会自动分割为多条发送。分割后的多条短信将按照具体占用条数计费。 | ||
14 | + | ||
15 | +echo $ucpass->SendSms($appid,$templateid,$param,$mobile,$uid); |
simplewind/vendor/sms/~$读我(重要).doc
0 → 100644
不能预览此文件类型
simplewind/vendor/sms/请先读我(重要).doc
0 → 100644
不能预览此文件类型
-
请 注册 或 登录 后发表评论