When my app attempted to upload and broadcast a MP4(14.7mb, duration 60s) in a Tweet, I received the following error.
So I changed the code and used(chunked init>finalize) it, but the result was no error, but the tweet didn’t come up.
Below is the result code, and I wonder if the tweets were not uploaded at the end of use.
[result code]
vardump(init)
object(stdClass)#3 (3) {
[“media_id”]=>
int(1171609924788318208)
[“media_id_string”]=>
string(19) “1171609924788318208”
[“expires_after_secs”]=>
int(86399)
}
vardump(finalize)
object(stdClass)#8 (5) {
[“media_id”]=>
int(1171609924788318208)
[“media_id_string”]=>
string(19) “1171609924788318208”
[“size”]=>
int(15337569)
[“expires_after_secs”]=>
int(86400)
[“video”]=>
object(stdClass)#9 (1) {
[“video_type”]=>
string(9) “video/mp4”
}
}
use
os : window 10
abraham twitter OAuth
develop languge : php
use mp4 file : https://mms.yaguin.com/test14.mp4
$parameters = [‘media’ => $twitter_mov_arr[0], ‘media_type’ => ‘video/mp4’];
//$twitter_mov_arr[0] = use mp4 file path
$path = ‘media/upload’;
$init = $connection->http(‘POST’, ‘https://upload.twitter.com’, $path, $connection->mediaInitParameters($parameters), false);
echo "\n----------------------\n";
echo "\nvardump(init)\n";
echo var_dump($init);
// Append
$segmentIndex = 0;
$media = fopen($parameters['media'], 'rb');
echo "\n----------------------\n";
echo "\nvardump(media)\n";
echo var_dump($media);
while (!feof($media)) {
$tmp = $connection->http('POST', 'https://upload.twitter.com', 'media/upload', [
'command' => 'APPEND',
'media_id' => $init->media_id_string,
'segment_index' => $segmentIndex++,
//'media_data' => base64_encode(fread($media, 1024*1024*3)),
'media' => base64_encode(fread($media, 1024*1024*3)),
], false);
echo "\n----------------------\n";
echo "\nvardump(tmp)\n";
echo var_dump($tmp);
}
fclose($media);
// Finalize
$finalize = $connection->http('POST', 'https://upload.twitter.com', 'media/upload', [
'command' => 'FINALIZE',
'media_id' => $init->media_id_string
], false);