废话少说直接上代码
<?php
if(isset($_FILES['file'])) {
$file = $_FILES['file'];
$headers = array(
'Accept: */*',
'Accept-Encoding: gzip, deflate, br',
'Accept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Content-Type: multipart/form-data; boundary=----WebKitFormBoundarywt1pMxJgab51elEB',
'Host: pic-up.meituan.com',
'Origin: https://czz.meituan.com',
'Pragma: no-cache',
'Referer: https://czz.meituan.com/',
'Sec-Fetch-Dest: empty',
'Sec-Fetch-Mode: cors',
'Sec-Fetch-Site: same-site',
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Edg/121.0.0.0',
'client-id: p5gfsvmw6qnwc45n000000000025bbf1',
'sec-ch-ua: "Not A(Brand";v="99", "Microsoft Edge";v="121", "Chromium";v="121"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "Windows"',
'token: 换自己的toekn'
);
$postData = "------WebKitFormBoundarywt1pMxJgab51elEB\r\n";
$postData .= 'Content-Disposition: form-data; name="file"; filename="' . $file['name'] . "\"\r\n";
$postData .= 'Content-Type: ' . $file['type'] . "\r\n\r\n";
$postData .= file_get_contents($file['tmp_name']) . "\r\n";
$postData .= "------WebKitFormBoundarywt1pMxJgab51elEB--\r\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://pic-up.meituan.com/extrastorage/new/video?isHttps=true');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if(curl_errno($ch)){
echo 'Curl error: ' . curl_error($ch);
exit;
}
curl_close($ch);
$jsonResponse = json_decode($response, true);
if(isset($jsonResponse['success']) && $jsonResponse['success'] === true) {
$originalLink = $jsonResponse['data']['originalLink'];
$originalFileName = $jsonResponse['data']['originalFileName'];
$newJson = array(
'Jobs' => $originalLink,
'Name' => $originalFileName,
'os'=>'node-oss.zai1.com'
);
echo json_encode($newJson);
} else {
echo json_encode(array('error' => 'Upload failed'));
}
} else {
echo "No file uploaded.";
}
?>
共有 0 条评论