Beyler twitter'a resim yükleyeceğim ama sürekli şu hatayı alıyorum. Medya parametresi yok diyor.

{"request":"\/i\/media\/upload.json","error":"media parameter is missing."}
CURL'yi yanlış mı ayarladım?

// APPEND request
$append_url = "https://upload.x.com/i/media/upload.json?command=APPEND&media_id=$media_id&segment_index=0";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $append_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$image_path = "a.jpg";
$file_data = base64_encode(file_get_contents($image_path));
$payload = json_encode([
    "command" => "APPEND",
    "media_id" => $media_id,
    "segment_index" => 0,
    "name" => "media",
]);
$fields = [
    'media' => $file_data
];

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$response = curl_exec($ch);
curl_close($ch);

// Sonuç
echo "2. Response: " . $response . "<br><br>";