1 | <?php |
||
9 | class Sms |
||
10 | { |
||
11 | private $auth; |
||
12 | private $baseURL; |
||
13 | |||
14 | public function __construct(Auth $auth) |
||
20 | |||
21 | /* |
||
22 | * 创建签名 |
||
23 | * signature: string 类型,必填, |
||
24 | * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为: |
||
25 | nterprises_and_institutions 企事业单位的全称或简称 |
||
26 | website 工信部备案网站的全称或简称 |
||
27 | app APP应用的全称或简称 |
||
28 | public_number_or_small_program 公众号或小程序的全称或简称 |
||
29 | store_name 电商平台店铺名的全称或简称 |
||
30 | trade_name 商标名的全称或简称, |
||
31 | * pics: 本地的图片路径 string 类型,可选 |
||
32 | */ |
||
33 | public function createSignature($signature, $source, $pics = null) |
||
45 | |||
46 | /* |
||
47 | * 编辑签名 |
||
48 | * id 签名id |
||
49 | * signature: string 类型,必填, |
||
50 | * source: string 类型,必填,申请签名时必须指定签名来源。取值范围为: |
||
51 | enterprises_and_institutions 企事业单位的全称或简称 |
||
52 | website 工信部备案网站的全称或简称 |
||
53 | app APP应用的全称或简称 |
||
54 | public_number_or_small_program 公众号或小程序的全称或简称 |
||
55 | store_name 电商平台店铺名的全称或简称 |
||
56 | trade_name 商标名的全称或简称, |
||
57 | * pics: 本地的图片路径 string 类型,可选, |
||
58 | */ |
||
59 | public function updateSignature($id, $signature, $source, $pics = null) |
||
71 | |||
72 | /* |
||
73 | * 查询签名 |
||
74 | * audit_status: 审核状态 string 类型,可选, |
||
75 | 取值范围为: "passed"(通过), "rejected"(未通过), "reviewing"(审核中) |
||
76 | * page:页码 int 类型, |
||
77 | * maxUsers:人数限制 ,可选,默认为 1 |
||
78 | * page_size: 分页大小 int 类型,可选, 默认为20 |
||
79 | */ |
||
80 | public function checkSignature($audit_status = null, $page = 1, $page_size = 20) |
||
93 | |||
94 | |||
95 | /* |
||
96 | * 删除签名 |
||
97 | * id 签名id |
||
98 | */ |
||
99 | public function deleteSignature($id) |
||
105 | |||
106 | |||
107 | |||
108 | |||
109 | /* |
||
110 | * 创建模板 |
||
111 | * name : 模板名称 string 类型 ,必填 |
||
112 | * template: 模板内容 string 类型,必填 |
||
113 | * type: 模板类型 string 类型,必填, |
||
114 | 取值范围为: notification (通知类短信), verification (验证码短信), marketing (营销类短信) |
||
115 | * description: 申请理由简述 string 类型,必填 |
||
116 | * signature_id: 已经审核通过的签名 string 类型,必填 |
||
117 | */ |
||
118 | public function createTemplate($name, $template, $type, $description, $signture_id) |
||
132 | |||
133 | /* |
||
134 | * 查询模板 |
||
135 | * audit_status: 审核状态 string 类型 ,可选, |
||
136 | 取值范围为: passed (通过), rejected (未通过), reviewing (审核中) |
||
137 | * page: 页码 int 类型,可选,默认为 1 |
||
138 | * page_size: 分页大小 int 类型,可选,默认为 20 |
||
139 | */ |
||
140 | public function queryTemplate($audit_status = null, $page = 1, $page_size = 20) |
||
153 | |||
154 | /* |
||
155 | * 编辑模板 |
||
156 | * id :模板id |
||
157 | * name : 模板名称 string 类型 ,必填 |
||
158 | * template: 模板内容 string 类型,必填 |
||
159 | * description: 申请理由简述 string 类型,必填 |
||
160 | * signature_id: 已经审核通过的签名 string 类型,必填 |
||
161 | */ |
||
162 | public function updateTemplate($id, $name, $template, $description, $signature_id) |
||
173 | |||
174 | /* |
||
175 | * 删除模板 |
||
176 | * id :模板id |
||
177 | */ |
||
178 | public function deleteTemplate($id) |
||
184 | |||
185 | /* |
||
186 | * 发送短信 |
||
187 | * 编辑模板 |
||
188 | * template_id :模板id string类型,必填 |
||
189 | * mobiles : 手机号数组 []string 类型 ,必填 |
||
190 | * parameters: 模板内容 map[string]string 类型,可选 |
||
191 | */ |
||
192 | public function sendMessage($template_id, $mobiles, array $parameters = null) |
||
204 | |||
205 | public function imgToBase64($img_file) |
||
238 | |||
239 | private function get($url, $cType = null) |
||
249 | |||
250 | private function delete($url, $contentType = 'application/json') |
||
260 | |||
261 | private function post($url, $body, $contentType = 'application/json') |
||
283 | } |
||
284 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.