From ec9cfd760a27690e8b5d173e23c3faf9bb2aab51 Mon Sep 17 00:00:00 2001 From: elf <360197197@qq.com> Date: Mon, 1 Apr 2024 23:57:02 +0800 Subject: [PATCH] test --- ip.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/ip.php b/ip.php index 3515a38..c2f9d25 100644 --- a/ip.php +++ b/ip.php @@ -1,2 +1,58 @@ $source, + 'X-Date' => $datetime, + 'Authorization' => $auth, + + ); + // 查询参数 + $queryParams = array ( + + ); + // body参数(POST方法下) + $bodyParams = array ( + 'ip' => '', + ); + // url参数拼接 + $url = 'https://service-hnhpr5tw-1305308687.gz.apigw.tencentcs.com/release/ip/query'; + if (count($queryParams) > 0) { + $url .= '?' . http_build_query($queryParams); + } + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, 60); + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); + curl_setopt($ch, CURLOPT_HTTPHEADER, array_map(function ($v, $k) { + return $k . ': ' . $v; + }, array_values($headers), array_keys($headers))); + if (in_array($method, array('POST', 'PUT', 'PATCH'), true)) { + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($bodyParams)); + } + + $data = curl_exec($ch); + if (curl_errno($ch)) { + echo "Error: " . curl_error($ch); + } else { + print_r($data); + } + curl_close($ch); +}