codebird-php icon indicating copy to clipboard operation
codebird-php copied to clipboard

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

Open dreinstein10 opened this issue 6 years ago • 7 comments

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 ]);`

dreinstein10 avatar Aug 10 '19 19:08 dreinstein10

did you solve it?

m7ammad7assan avatar Oct 19 '19 09:10 m7ammad7assan

same here

JoseLuisFriedrich avatar Sep 05 '20 19:09 JoseLuisFriedrich

any solution here?

cristisocialboost avatar Apr 26 '21 07:04 cristisocialboost

Anyone found a solution?

roberttolton avatar Aug 26 '22 15:08 roberttolton