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
| <?php
| // 短信发送工具类
| class SmsUtils{
| // 获取时间戳
| public static function getTimestamp() {
| return time() * 1000;
| }
|
| // 生成sign
| public static function generateSign($account, $password, $timestamp) {
| $value = $account . $timestamp . md5($password);
| return md5($value);
| }
|
| // post请求
| public static function send($url, $data) {
| // 定义请求选项
| $options = [
| 'http' => [
| 'header' => "Content-Type: application/json;charset=utf-8\r\nAccept: application/json\r\n",
| 'method' => 'POST',
| 'content' => json_encode($data)
| ]
| ];
| // 发送 HTTP 请求
| $context = stream_context_create($options);
| $result = file_get_contents($url, false, $context);
| return $result;
| }
| }
| ?>
|
|