Last active 1728468770

penn revised this gist 1728468769. Go to revision

1 file changed, 31 insertions

gistfile1.txt(file created)

@@ -0,0 +1,31 @@
1 + <?php
2 + $curl = curl_init();
3 + curl_setopt_array($curl, array(
4 + CURLOPT_URL => "https://v2.api-m.com/api/heisi",
5 + CURLOPT_RETURNTRANSFER => true,
6 + CURLOPT_ENCODING => '',
7 + CURLOPT_MAXREDIRS => 10,
8 + CURLOPT_TIMEOUT => 30,
9 + CURLOPT_FOLLOWLOCATION => true,
10 + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
11 + CURLOPT_CUSTOMREQUEST => 'GET',
12 + ));
13 + $response = curl_exec($curl);
14 + if(curl_errno($curl)){
15 + echo 'Request Error:' . curl_error($curl);
16 + }
17 + curl_close($curl);
18 + $json = $response;
19 + $data = json_decode($json, true);
20 + if ($data && isset($data['data']) && filter_var($data['data'], FILTER_VALIDATE_URL)) {
21 + $imageUrl = $data['data'];
22 + $html = <<<HTML
23 + <script>
24 + window.location.href = "$imageUrl";
25 + </script>
26 + HTML;
27 + echo $html;
28 + } else {
29 + echo "无法解析数据或数据字段不存在。";
30 + }
31 + ?>
Newer Older