@@ -20,69 +20,88 @@ public function __construct(Auth $auth)
2020
2121 /*
2222 * 创建签名
23- * signature: string 类型,必填,
24- * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
23+ * signature: string 类型,必填,【长度限制8个字符内】超过长度会报错
24+ * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
2525 nterprises_and_institutions 企事业单位的全称或简称
2626 website 工信部备案网站的全称或简称
2727 app APP应用的全称或简称
2828 public_number_or_small_program 公众号或小程序的全称或简称
2929 store_name 电商平台店铺名的全称或简称
3030 trade_name 商标名的全称或简称,
31- * pics: 本地的图片路径 string 类型,可选
31+ * pics: 本地的图片路径 string 类型,可选
32+ *@return: 类型array {
33+ "signature_id": <signature_id>
34+ }
3235 */
33- public function createSignature ($ signature , $ source , $ pics = null )
36+ public function createSignature (string $ signature , string $ source , string $ pics = null )
3437 {
3538 $ params ['signature ' ] = $ signature ;
3639 $ params ['source ' ] = $ source ;
3740 if (!empty ($ pics )) {
3841 $ params ['pics ' ] = $ this ->imgToBase64 ($ pics );
3942 }
4043 $ body = json_encode ($ params );
41- $ url =$ this ->baseURL ." signature " ;
44+ $ url =$ this ->baseURL .' signature ' ;
4245 $ ret = $ this ->post ($ url , $ body );
4346 return $ ret ;
4447 }
4548
4649 /*
4750 * 编辑签名
48- * id 签名id
51+ * id 签名id : string 类型,必填,
4952 * signature: string 类型,必填,
50- * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
53+ * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为:
5154 enterprises_and_institutions 企事业单位的全称或简称
5255 website 工信部备案网站的全称或简称
5356 app APP应用的全称或简称
5457 public_number_or_small_program 公众号或小程序的全称或简称
5558 store_name 电商平台店铺名的全称或简称
5659 trade_name 商标名的全称或简称,
57- * pics: 本地的图片路径 string 类型,可选,
60+ * pics: 本地的图片路径 string 类型,可选,
61+ * @return: 类型array {
62+ "signature": string
63+ }
5864 */
59- public function updateSignature ($ id , $ signature , $ source , $ pics = null )
65+ public function updateSignature (string $ id , string $ signature , string $ source , string $ pics = null )
6066 {
6167 $ params ['signature ' ] = $ signature ;
6268 $ params ['source ' ] = $ source ;
6369 if (!empty ($ pics )) {
6470 $ params ['pics ' ] = $ this ->imgToBase64 ($ pics );
6571 }
6672 $ body = json_encode ($ params );
67- $ url =$ this ->baseURL ." signature/ " .$ id ;
73+ $ url =$ this ->baseURL .' signature/ ' .$ id ;
6874 $ ret = $ this ->PUT ($ url , $ body );
6975 return $ ret ;
7076 }
7177
7278 /*
7379 * 查询签名
74- * audit_status: 审核状态 string 类型,可选,
80+ * audit_status: 审核状态 string 类型,可选,
7581 取值范围为: "passed"(通过), "rejected"(未通过), "reviewing"(审核中)
7682 * page:页码 int 类型,
77- * maxUsers:人数限制 ,可选,默认为 1
7883 * 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+ }
7998 */
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 )
81100 {
82101
83102 $ url = sprintf (
84103 "%s?audit_status=%s&page=%s&page_size=%s " ,
85- $ this ->baseURL ." signature " ,
104+ $ this ->baseURL .' signature ' ,
86105 $ audit_status ,
87106 $ page ,
88107 $ page_size
@@ -94,9 +113,10 @@ public function checkSignature($audit_status = null, $page = 1, $page_size = 20)
94113
95114 /*
96115 * 删除签名
97- * id 签名id
116+ * id 签名id string 类型,必填,
117+ * @retrun : 请求成功 HTTP 状态码为 200
98118 */
99- public function deleteSignature ($ id )
119+ public function deleteSignature (string $ id )
100120 {
101121 $ url = $ this ->baseURL . 'signature/ ' . $ id ;
102122 list (, $ err ) = $ this ->delete ($ url );
@@ -108,24 +128,31 @@ public function deleteSignature($id)
108128
109129 /*
110130 * 创建模板
111- * name : 模板名称 string 类型 ,必填
131+ * name : 模板名称 string 类型 ,必填
112132 * template: 模板内容 string 类型,必填
113133 * type: 模板类型 string 类型,必填,
114134 取值范围为: notification (通知类短信), verification (验证码短信), marketing (营销类短信)
115135 * description: 申请理由简述 string 类型,必填
116136 * signature_id: 已经审核通过的签名 string 类型,必填
137+ * @return: 类型 array {
138+ "template_id": string
139+ }
117140 */
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+ ) {
120148 $ params ['name ' ] = $ name ;
121149 $ params ['template ' ] = $ template ;
122150 $ params ['type ' ] = $ type ;
123151 $ params ['description ' ] = $ description ;
124152 $ params ['signature_id ' ] = $ signture_id ;
125153
126154 $ body = json_encode ($ params );
127- var_dump ($ body );
128- $ url =$ this ->baseURL ."template " ;
155+ $ url =$ this ->baseURL .'template ' ;
129156 $ ret = $ this ->post ($ url , $ body );
130157 return $ ret ;
131158 }
@@ -136,13 +163,30 @@ public function createTemplate($name, $template, $type, $description, $signture_
136163 取值范围为: passed (通过), rejected (未通过), reviewing (审核中)
137164 * page: 页码 int 类型,可选,默认为 1
138165 * 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+ }
139183 */
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 )
141185 {
142186
143187 $ url = sprintf (
144188 "%s?audit_status=%s&page=%s&page_size=%s " ,
145- $ this ->baseURL ." template " ,
189+ $ this ->baseURL .' template ' ,
146190 $ audit_status ,
147191 $ page ,
148192 $ page_size
@@ -154,28 +198,35 @@ public function queryTemplate($audit_status = null, $page = 1, $page_size = 20)
154198 /*
155199 * 编辑模板
156200 * id :模板id
157- * name : 模板名称 string 类型 ,必填
201+ * name : 模板名称 string 类型 ,必填
158202 * template: 模板内容 string 类型,必填
159203 * description: 申请理由简述 string 类型,必填
160204 * signature_id: 已经审核通过的签名 string 类型,必填
205+ * @retrun : 请求成功 HTTP 状态码为 200
161206 */
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+ ) {
164214 $ params ['name ' ] = $ name ;
165215 $ params ['template ' ] = $ template ;
166216 $ params ['description ' ] = $ description ;
167217 $ params ['signature_id ' ] = $ signature_id ;
168218 $ body = json_encode ($ params );
169- $ url =$ this ->baseURL ." template/ " .$ id ;
219+ $ url =$ this ->baseURL .' template/ ' .$ id ;
170220 $ ret = $ this ->PUT ($ url , $ body );
171221 return $ ret ;
172222 }
173223
174224 /*
175225 * 删除模板
176- * id :模板id
226+ * id :模板id string 类型,必填,
227+ * @retrun : 请求成功 HTTP 状态码为 200
177228 */
178- public function deleteTemplate ($ id )
229+ public function deleteTemplate (string $ id )
179230 {
180231 $ url = $ this ->baseURL . 'template/ ' . $ id ;
181232 list (, $ err ) = $ this ->delete ($ url );
@@ -186,23 +237,26 @@ public function deleteTemplate($id)
186237 * 发送短信
187238 * 编辑模板
188239 * 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+ }
191245 */
192- public function sendMessage ($ template_id , $ mobiles , array $ parameters = null )
246+ public function sendMessage (string $ template_id , array $ mobiles , array $ parameters = null )
193247 {
194248 $ params ['template_id ' ] = $ template_id ;
195249 $ params ['mobiles ' ] = $ mobiles ;
196250 if (!empty ($ parameters )) {
197251 $ params ['parameters ' ] = $ parameters ;
198252 }
199253 $ body = json_encode ($ params );
200- $ url =$ this ->baseURL ." message " ;
254+ $ url =$ this ->baseURL .' message ' ;
201255 $ ret = $ this ->post ($ url , $ body );
202256 return $ ret ;
203257 }
204258
205- public function imgToBase64 ($ img_file )
259+ public function imgToBase64 (string $ img_file )
206260 {
207261 $ img_base64 = '' ;
208262 if (file_exists ($ img_file )) {
@@ -212,19 +266,19 @@ public function imgToBase64($img_file)
212266 if ($ fp ) {
213267 $ filesize = filesize ($ app_img_file );
214268 if ($ filesize > 5 *1024 *1024 ) {
215- new Error ("pic size < 5M ! " );
269+ die ("pic size < 5M ! " );
216270 }
217271 $ content = fread ($ fp , $ filesize );
218272 $ file_content = chunk_split (base64_encode ($ content )); // base64编码
219273 switch ($ img_info [2 ]) { //判读图片类型
220274 case 1 :
221- $ img_type = " gif " ;
275+ $ img_type = ' gif ' ;
222276 break ;
223277 case 2 :
224- $ img_type = " jpg " ;
278+ $ img_type = ' jpg ' ;
225279 break ;
226280 case 3 :
227- $ img_type = " png " ;
281+ $ img_type = ' png ' ;
228282 break ;
229283 }
230284 //合成图片的base64编码
0 commit comments