Files
Fuxsto-V4/More/Get.php
2025-10-17 23:27:39 +08:00

51 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
include_once "../Main/Hv4.Function.php";
$url = 'https://www.007idc.cn/v1/login_api';
$payload = [
'account' => '19884551721',
'password' => 'LX5bH76SJf9E'
];
// 初始化cURL
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 返回响应内容而不直接输出
curl_setopt($ch, CURLOPT_POST, true); // 使用POST方法
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/json' // 设置JSON头
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); // JSON编码数据
// 执行请求
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
// 处理响应
if ($httpCode === 200) {
$data = json_decode($response);
if (isset($data->jwt)) {
$jwt = $data->jwt;
$file = 'jwt.txt';
// 将数据写入文件
file_put_contents($file, $jwt);
} else {
echo "响应中缺少JWT令牌";
}
} else {
echo "认证失败,错误信息:" . ($response ?: '无响应内容');
}
// 错误处理
if ($error) {
echo "cURL错误" . $error;
}