API接口:https://kefu-jtalk.jd.com/jtalk/hfive/resource/image/upload
上传参数:
image => 图片

<?php

// 京东客服图床接口
// By: Linuors

if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['file'])) {
    $apiUrl = 'https://kefu-jtalk.jd.com/jtalk/hfive/resource/image/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 = ['image' => $cFile];
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);
    
    $responseData = json_decode($response, true);
    if (isset($responseData['data']) && !empty($responseData['data'][0]['url'])) {
        echo $responseData['data'][0]['url'];
    } else {
        echo $response;
    }

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