Upload GIF with INIT/APPEND/FINALIZE doesn't works

php

#1

Hi,

I use TwitterOauth (abraham) to upload my GIF (size: 2 841 436 bytes).

My code:

require 'vendor/autoload.php';

use Abraham\TwitterOAuth\TwitterOAuth;

$connection = new TwitterOAuth(,,,);

$media_init = $connection->upload('media/upload', [
'command' => 'INIT',
'total_bytes' => '2841436',
'media_category' => 'tweet_gif',
'media_type' => 'image/gif'
]);

var_dump($media_init);

$media_append = $connection->upload('media/upload', [
'command' => 'APPEND',
'media_id' => $media_init->media_id_string,
'media' => 'my_file_here.gif',
'segment_index' => '0'
]);

var_dump($media_append);

$media_finalize = $connection->upload('media/upload', [
'command' => 'FINALIZE',
'media_id' => $media_init->media_id_string
]);

var_dump($media_finalize);

$media = $connection->upload('media/upload', [
'command' => 'STATUS',
'media_id' => $media_init->media_id_string
]);

Result:

stdClass Object
(
    [media_id] => 722495126199779329
    [media_id_string] => 722495126199779329
    [expires_after_secs] => 86399
)

stdClass Object
(
    [media_id] => 722495126199779329
    [media_id_string] => 722495126199779329
    [size] => 2841436
    [expires_after_secs] => 86400
    [processing_info] => stdClass Object
        (
            [state] => pending
            [check_after_secs] => 5
        )
)

stdClass Object
(
    [request] => /1.1/media/upload.json
    [error] => media type unrecognized.
)

But impossible to get the GIF media :confused:

Could you help me please?

Thanks, very much!


#2

Up please :slight_smile: