@@ -20,69 +20,88 @@ public function __construct(Auth $auth)
20
20
21
21
/*
22
22
* 创建签名
23
- * signature: string 类型,必填,
24
- * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
23
+ * signature: string 类型,必填,【长度限制8个字符内】超过长度会报错
24
+ * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
25
25
nterprises_and_institutions 企事业单位的全称或简称
26
26
website 工信部备案网站的全称或简称
27
27
app APP应用的全称或简称
28
28
public_number_or_small_program 公众号或小程序的全称或简称
29
29
store_name 电商平台店铺名的全称或简称
30
30
trade_name 商标名的全称或简称,
31
- * pics: 本地的图片路径 string 类型,可选
31
+ * pics: 本地的图片路径 string 类型,可选
32
+ *@return: 类型array {
33
+ "signature_id": <signature_id>
34
+ }
32
35
*/
33
- public function createSignature ($ signature , $ source , $ pics = null )
36
+ public function createSignature (string $ signature , string $ source , string $ pics = null )
34
37
{
35
38
$ params ['signature ' ] = $ signature ;
36
39
$ params ['source ' ] = $ source ;
37
40
if (!empty ($ pics )) {
38
41
$ params ['pics ' ] = $ this ->imgToBase64 ($ pics );
39
42
}
40
43
$ body = json_encode ($ params );
41
- $ url =$ this ->baseURL ." signature " ;
44
+ $ url =$ this ->baseURL .' signature ' ;
42
45
$ ret = $ this ->post ($ url , $ body );
43
46
return $ ret ;
44
47
}
45
48
46
49
/*
47
50
* 编辑签名
48
- * id 签名id
51
+ * id 签名id : string 类型,必填,
49
52
* signature: string 类型,必填,
50
- * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
53
+ * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
51
54
enterprises_and_institutions 企事业单位的全称或简称
52
55
website 工信部备案网站的全称或简称
53
56
app APP应用的全称或简称
54
57
public_number_or_small_program 公众号或小程序的全称或简称
55
58
store_name 电商平台店铺名的全称或简称
56
59
trade_name 商标名的全称或简称,
57
- * pics: 本地的图片路径 string 类型,可选,
60
+ * pics: 本地的图片路径 string 类型,可选,
61
+ * @return: 类型array {
62
+ "signature": string
63
+ }
58
64
*/
59
- public function updateSignature ($ id , $ signature , $ source , $ pics = null )
65
+ public function updateSignature (string $ id , string $ signature , string $ source , string $ pics = null )
60
66
{
61
67
$ params ['signature ' ] = $ signature ;
62
68
$ params ['source ' ] = $ source ;
63
69
if (!empty ($ pics )) {
64
70
$ params ['pics ' ] = $ this ->imgToBase64 ($ pics );
65
71
}
66
72
$ body = json_encode ($ params );
67
- $ url =$ this ->baseURL ." signature/ " .$ id ;
73
+ $ url =$ this ->baseURL .' signature/ ' .$ id ;
68
74
$ ret = $ this ->PUT ($ url , $ body );
69
75
return $ ret ;
70
76
}
71
77
72
78
/*
73
79
* 查询签名
74
- * audit_status: 审核状态 string 类型,可选,
80
+ * audit_status: 审核状态 string 类型,可选,
75
81
取值范围为: "passed"(通过), "rejected"(未通过), "reviewing"(审核中)
76
82
* page:页码 int 类型,
77
- * maxUsers:人数限制 ,可选,默认为 1
78
83
* page_size: 分页大小 int 类型,可选, 默认为20
84
+ *@return: 类型array {
85
+ "items": [{
86
+ "id": string,
87
+ "signature": string,
88
+ "source": string,
89
+ "audit_status": string,
90
+ "reject_reason": string,
91
+ "created_at": int64,
92
+ "updated_at": int64
93
+ }...],
94
+ "total": int,
95
+ "page": int,
96
+ "page_size": int,
97
+ }
79
98
*/
80
- public function checkSignature ($ audit_status = null , $ page = 1 , $ page_size = 20 )
99
+ public function checkSignature (string $ audit_status = null , int $ page = 1 , int $ page_size = 20 )
81
100
{
82
101
83
102
$ url = sprintf (
84
103
"%s?audit_status=%s&page=%s&page_size=%s " ,
85
- $ this ->baseURL ." signature " ,
104
+ $ this ->baseURL .' signature ' ,
86
105
$ audit_status ,
87
106
$ page ,
88
107
$ page_size
@@ -94,9 +113,10 @@ public function checkSignature($audit_status = null, $page = 1, $page_size = 20)
94
113
95
114
/*
96
115
* 删除签名
97
- * id 签名id
116
+ * id 签名id string 类型,必填,
117
+ * @retrun : 请求成功 HTTP 状态码为 200
98
118
*/
99
- public function deleteSignature ($ id )
119
+ public function deleteSignature (string $ id )
100
120
{
101
121
$ url = $ this ->baseURL . 'signature/ ' . $ id ;
102
122
list (, $ err ) = $ this ->delete ($ url );
@@ -108,24 +128,31 @@ public function deleteSignature($id)
108
128
109
129
/*
110
130
* 创建模板
111
- * name : 模板名称 string 类型 ,必填
131
+ * name : 模板名称 string 类型 ,必填
112
132
* template: 模板内容 string 类型,必填
113
133
* type: 模板类型 string 类型,必填,
114
134
取值范围为: notification (通知类短信), verification (验证码短信), marketing (营销类短信)
115
135
* description: 申请理由简述 string 类型,必填
116
136
* signature_id: 已经审核通过的签名 string 类型,必填
137
+ * @return: 类型 array {
138
+ "template_id": string
139
+ }
117
140
*/
118
- public function createTemplate ($ name , $ template , $ type , $ description , $ signture_id )
119
- {
141
+ public function createTemplate (
142
+ string $ name ,
143
+ string $ template ,
144
+ string $ type ,
145
+ string $ description ,
146
+ string $ signture_id
147
+ ) {
120
148
$ params ['name ' ] = $ name ;
121
149
$ params ['template ' ] = $ template ;
122
150
$ params ['type ' ] = $ type ;
123
151
$ params ['description ' ] = $ description ;
124
152
$ params ['signature_id ' ] = $ signture_id ;
125
153
126
154
$ body = json_encode ($ params );
127
- var_dump ($ body );
128
- $ url =$ this ->baseURL ."template " ;
155
+ $ url =$ this ->baseURL .'template ' ;
129
156
$ ret = $ this ->post ($ url , $ body );
130
157
return $ ret ;
131
158
}
@@ -136,13 +163,30 @@ public function createTemplate($name, $template, $type, $description, $signture_
136
163
取值范围为: passed (通过), rejected (未通过), reviewing (审核中)
137
164
* page: 页码 int 类型,可选,默认为 1
138
165
* page_size: 分页大小 int 类型,可选,默认为 20
166
+ * @return: 类型array{
167
+ "items": [{
168
+ "id": string,
169
+ "name": string,
170
+ "template": string,
171
+ "audit_status": string,
172
+ "reject_reason": string,
173
+ "type": string,
174
+ "signature_id": string, // 模版绑定的签名ID
175
+ "signature_text": string, // 模版绑定的签名内容
176
+ "created_at": int64,
177
+ "updated_at": int64
178
+ }...],
179
+ "total": int,
180
+ "page": int,
181
+ "page_size": int
182
+ }
139
183
*/
140
- public function queryTemplate ($ audit_status = null , $ page = 1 , $ page_size = 20 )
184
+ public function queryTemplate (string $ audit_status = null , int $ page = 1 , int $ page_size = 20 )
141
185
{
142
186
143
187
$ url = sprintf (
144
188
"%s?audit_status=%s&page=%s&page_size=%s " ,
145
- $ this ->baseURL ." template " ,
189
+ $ this ->baseURL .' template ' ,
146
190
$ audit_status ,
147
191
$ page ,
148
192
$ page_size
@@ -154,28 +198,35 @@ public function queryTemplate($audit_status = null, $page = 1, $page_size = 20)
154
198
/*
155
199
* 编辑模板
156
200
* id :模板id
157
- * name : 模板名称 string 类型 ,必填
201
+ * name : 模板名称 string 类型 ,必填
158
202
* template: 模板内容 string 类型,必填
159
203
* description: 申请理由简述 string 类型,必填
160
204
* signature_id: 已经审核通过的签名 string 类型,必填
205
+ * @retrun : 请求成功 HTTP 状态码为 200
161
206
*/
162
- public function updateTemplate ($ id , $ name , $ template , $ description , $ signature_id )
163
- {
207
+ public function updateTemplate (
208
+ string $ id ,
209
+ string $ name ,
210
+ string $ template ,
211
+ string $ description ,
212
+ string $ signature_id
213
+ ) {
164
214
$ params ['name ' ] = $ name ;
165
215
$ params ['template ' ] = $ template ;
166
216
$ params ['description ' ] = $ description ;
167
217
$ params ['signature_id ' ] = $ signature_id ;
168
218
$ body = json_encode ($ params );
169
- $ url =$ this ->baseURL ." template/ " .$ id ;
219
+ $ url =$ this ->baseURL .' template/ ' .$ id ;
170
220
$ ret = $ this ->PUT ($ url , $ body );
171
221
return $ ret ;
172
222
}
173
223
174
224
/*
175
225
* 删除模板
176
- * id :模板id
226
+ * id :模板id string 类型,必填,
227
+ * @retrun : 请求成功 HTTP 状态码为 200
177
228
*/
178
- public function deleteTemplate ($ id )
229
+ public function deleteTemplate (string $ id )
179
230
{
180
231
$ url = $ this ->baseURL . 'template/ ' . $ id ;
181
232
list (, $ err ) = $ this ->delete ($ url );
@@ -186,23 +237,26 @@ public function deleteTemplate($id)
186
237
* 发送短信
187
238
* 编辑模板
188
239
* template_id :模板id string类型,必填
189
- * mobiles : 手机号数组 []string 类型 ,必填
190
- * parameters: 模板内容 map[string]string 类型,可选
240
+ * mobiles : 手机号数组 []string 类型 ,必填
241
+ * parameters: 模板内容 map[string]string 类型,可选
242
+ * @return: 类型json {
243
+ "job_id": string
244
+ }
191
245
*/
192
- public function sendMessage ($ template_id , $ mobiles , array $ parameters = null )
246
+ public function sendMessage (string $ template_id , array $ mobiles , array $ parameters = null )
193
247
{
194
248
$ params ['template_id ' ] = $ template_id ;
195
249
$ params ['mobiles ' ] = $ mobiles ;
196
250
if (!empty ($ parameters )) {
197
251
$ params ['parameters ' ] = $ parameters ;
198
252
}
199
253
$ body = json_encode ($ params );
200
- $ url =$ this ->baseURL ." message " ;
254
+ $ url =$ this ->baseURL .' message ' ;
201
255
$ ret = $ this ->post ($ url , $ body );
202
256
return $ ret ;
203
257
}
204
258
205
- public function imgToBase64 ($ img_file )
259
+ public function imgToBase64 (string $ img_file )
206
260
{
207
261
$ img_base64 = '' ;
208
262
if (file_exists ($ img_file )) {
@@ -212,19 +266,19 @@ public function imgToBase64($img_file)
212
266
if ($ fp ) {
213
267
$ filesize = filesize ($ app_img_file );
214
268
if ($ filesize > 5 *1024 *1024 ) {
215
- new Error ("pic size < 5M ! " );
269
+ die ("pic size < 5M ! " );
216
270
}
217
271
$ content = fread ($ fp , $ filesize );
218
272
$ file_content = chunk_split (base64_encode ($ content )); // base64编码
219
273
switch ($ img_info [2 ]) { //判读图片类型
220
274
case 1 :
221
- $ img_type = " gif " ;
275
+ $ img_type = ' gif ' ;
222
276
break ;
223
277
case 2 :
224
- $ img_type = " jpg " ;
278
+ $ img_type = ' jpg ' ;
225
279
break ;
226
280
case 3 :
227
- $ img_type = " png " ;
281
+ $ img_type = ' png ' ;
228
282
break ;
229
283
}
230
284
//合成图片的base64编码
0 commit comments