API接口:https://api.da8m.cn/api/upload
上传参数:
file =>图片
需要携带请求头token,随机生成一个md5值即可

<?php

// DA8M团购图床接口
// By: Linuors

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
    $apiUrl = 'https://api.da8m.cn/api/upload';

    $file = $_FILES['file'];

    if ($file['error'] !== UPLOAD_ERR_OK) {
        http_response_code(400);
        echo json_encode(['error' => 'File upload error.']);
        exit;
    }

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $apiUrl);
    curl_setopt($ch, CURLOPT_POST, 1);
    $cFile = new CURLFile($file['tmp_name'], $file['type'], $file['name']);
    $postData = ['file' => $cFile];
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'token: 4ca04a3ff8ca3b8f0f8cfa01899ddf8e'
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    
    $responseData = json_decode($response, true);
    if ($responseData && isset($responseData['imgurl'])) {
        $imageUrl = $responseData['imgurl'];
        echo 'https://assets.da8m.cn/' . $imageUrl;
    } else {
        echo $response;
    }

} else {
    http_response_code(400);
    echo json_encode(['error' => 'No file uploaded.']);
}
?>