Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEDIA/UPLOAD-STATUS "media parameter is missing." #252

Open
dreinstein10 opened this issue Aug 10, 2019 · 7 comments
Open

MEDIA/UPLOAD-STATUS "media parameter is missing." #252

dreinstein10 opened this issue Aug 10, 2019 · 7 comments

Comments

@dreinstein10
Copy link

dreinstein10 commented Aug 10, 2019

Hi, I've been trying to post a video using the media_upload function but when I try to get the STATUS of the media_id I get the following error:
[code] => 38 , [message] => media parameter is missing.

I need to use the STATUS because if I try to FINALIZE the media I get a 'processing_info' in the reply saying the media status is 'pending', so I need to check the status until the status is 'succeeded'.

Does anybody else get this error?

Here's my code:

`$size_bytes = filesize($file);
$fp = fopen($file, 'r');

// INIT the upload
$reply = $cb->media_upload([
'command' => 'INIT',
'media_type' => 'video/mp4',
'media_category' => 'tweet_video',
'total_bytes' => $size_bytes
]);
$media_id = $reply->media_id_string;

// APPEND data to the upload
$segment_id = 0;
while (! feof($fp)) {
$chunk = fread($fp, 1048576); // 1MB per chunk for this sample
$reply = $cb->media_upload([
'command' => 'APPEND',
'media_id' => $media_id,
'segment_index' => $segment_id,
'media' => $chunk
]);
$segment_id++;
}
fclose($fp);

do{
sleep(10);
$status_reply = $cb->media_upload(['command' => 'STATUS',
'media_id'=> $media_id //media id from INIT
]);

var_dump($status_reply );
}while($status_reply->processing_info->state != 'failed' && $status_reply->processing_info->state != 'succeeded');

// FINALIZE the upload
$reply = $cb->media_upload([
'command' => 'FINALIZE',
'media_id' => $media_id
]);
var_dump($reply);
if ($reply->httpstatus < 200 || $reply->httpstatus > 299) {
die();
}

// Now use the media_id in a Tweet
$reply = $cb->statuses_update([
'status' => 'Twitter now accepts video uploads.',
'media_ids' => $media_id
]);`

@m7ammad7assan
Copy link

did you solve it?

@JoseLuisFriedrich
Copy link

same here

@cristisocialboost
Copy link

any solution here?

@roberttolton
Copy link

Anyone found a solution?

@toddfries
Copy link

I can't figure it out either, different language.

This works:

https://github.com/xdevplatform/large-video-upload-python/blob/b127c43d6b30663455dc1ee604b7ee042cc00b73/async-upload.py#L145

This doesn't:

https://github.com/toddfries/xapi/blob/master/xposts#L1267

chunk_check_status: state=pending, check_after_secs=1: media parameter is missing. at /usr/local/libdata/perl5/site_perl/X/API.pm line 367
(the X/API.pm just throws an error based on the http error)

@toddfries
Copy link

Looking at the source in this repo helped me fix the problem. Here's the fix in my code:

toddfries/xapi@6ae0984

(get not post)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants