i ma uploading media video 2mb size in chanked but it was showing me error hear is example code.
code:
$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" => 3000000,
'media_type' => 'video/mp4']
);
var_dump($code);
$video_media_id = $code->media_id_string;
$fp = fopen($video, 'r');
$segment_id = 0;
echo feof($fp);
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);
echo '------------------------------------------------------<br>';
$parameters = [
'status' => 'hear is my video twittsvbn',
'media_id' => $video_media_id
];
print_r($parameters);
echo '------------------------------------------------------<br>';
$tweet= $twitter->post('statuses/update', $parameters);
echo json_encode($tweet);
Hear is error will show
object(stdClass)#946 (2) {
["request"]=>
string(22) "/1.1/media/upload.json"
["error"]=>
string(51) "Segments do not add up to provided total file size."
}