hear is my code it's showing me error when i am uploading video on twitter
<?php
$video = 'images/video1.mp4'; /// video size is 2 mb and it's time duration around 20 seconeds
$code = $twitter->upload('media/upload',
["command" => "INIT",
"total_bytes" => (int)filesize($video),
'media_type' => 'video/mp4']
);
var_dump($code);
$video_media_id = $code->media_id_string;
$fp = fopen($video, 'r');
$segment_id = 0;
while (! feof($fp)) {
$chunk = fread($fp, 1048576); // 1MB per chunk for this sample
$twitter->upload('media/upload',
["command" => "APPEND",
"media_id" => $video_media_id,
"media_data" => base64_encode($chunk),
"segment_index" => $segment_id]
);
$segment_id++;
}
$final=$twitter->upload('media/upload',
["command" => "FINALIZE",
"media_id" => $video_media_id]
);
var_dump($final);
$parameters = [
'status' => 'hear is my video twittsvbn',
'media_id' => $video_media_id
];
print_r($parameters);
$tweet= $twitter->post('statuses/update', $parameters);
echo json_encode($tweet);
?>
it was showing me error object(stdClass)#933 (2) { ["request"]=> string(22) "/1.1/media/upload.json" ["error"]=> string(51) "Segments do not add up to provided total file size." }