Closed javayoung closed 7 years ago
Hi javayoung,
I also encountered the same issue but I was able to pinpoint the problem.
When using 'media_category' on INIT command, you must check the 'processing_info' field on the reply when you FINALIZE the upload. You need to have a state = 'succeeded' before proceeding on tweet creation. The error not_valid_video is because you are making a tweet for an uploaded video that is not ready or fully processed yet.
E.g. on my FINALIZE command response { "media_id":806584476478291968, "media_id_string":"806584476478291968", "size":27328440, "expires_after_secs":86400, "processing_info":{ "state":"pending", "check_after_secs":5 } }
You need to poll for update using the STATUS command until the state on processing info is equal to 'succeeded'.
E.g. on my STATUS command response { "media_id":806584476478291968, "media_id_string":"806584476478291968", "size":27328440, "expires_after_secs":86397, "video":{ "video_type":"video\/mp4" }, "processing_info":{ "state":"succeeded", "progress_percent":100 } }
But Issuing the STATUS command with codebird, I believe, is not supported yet which I open an issue here: https://github.com/jublonet/codebird-php/issues/190, at least based on what I saw on the code but I will be glad if I am corrected.
Thank you so much, Aironlio.
You are great and you are the only person who know how to fix it.
I have a question about your mentioned solution. "poll for update using the STATUS command until the state on processing info is equal to 'succeeded'."
Do you mean the program should continue to call status command to poll for update until the status is succeeded in a time frame say 5 minutes? May you inform me what is the status command request structure? Codebird may not has status command. Can i use standard http request to do that?
Thank you very much
Jarvis
From: aironlio notifications@github.com Sent: December 7, 2016 3:29 PM To: jublonet/codebird-php Cc: javayoung; Author Subject: Re: [jublonet/codebird-php] Can not post video with duration > 30 seconds (#188)
Hi javayoung,
I also encountered the same issue but I was able to pinpoint the problem.
When using 'media_category' on INIT command, you must check the 'processing_info' field on the reply when you FINALIZE the upload. You need to have a state = 'succeeded' before proceeding on tweet creation. The error not_valid_video is because you are making a tweet for an uploaded video that is not ready or fully processed yet.
E.g. on my FINALIZE command response { "media_id":806584476478291968, "media_id_string":"806584476478291968", "size":27328440, "expires_after_secs":86400, "processing_info":{ "state":"pending", "check_after_secs":5 } }
You need to poll for update using the STATUS command until the state on processing info is equal to 'succeeded'.
E.g. on my STATUS command response { "media_id":806584476478291968, "media_id_string":"806584476478291968", "size":27328440, "expires_after_secs":86397, "video":{ "video_type":"video/mp4" }, "processing_info":{ "state":"succeeded", "progress_percent":100 } }
But Issuing the STATUS command with codebird, I believe, is not supported yet which I open an issue here: #190https://github.com/jublonet/codebird-php/issues/190, at least based on what I saw on the code but I will be glad if I am corrected.
- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jublonet/codebird-php/issues/188#issuecomment-265564172, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADQymhpTaJq5u_EqHFtgsFPax-2kkK7fks5rFxc5gaJpZM4K7yR5.
Hi javayoung,
Yes, you have to call status command after an async media/upload request until the processing_info 'state' field is = 'succeeded' to make sure that the media processing is already 100%. But I won't suggest to give a constant time frame like 5 min. It would be pointless if you use a longer time if what you only need is less than that. I think the processing time of the uploaded media depends on how big the file is. Instead, use the field 'check_after_secs' to set a delay in polling for the update. But that depends on your implementation, as in my case I set a loop with a delay until such time I get the 'succeeded' response.
As of the current writing, Codebird has already support for this on version 3.2.0 but not release yet. You can use that version if you want, or you can wait for the stable release. But, if you are really in a hurry you can check https://github.com/jublonet/codebird-php/blob/develop/src/codebird.php @version 3.2.0-dev line 1681 to line 1687 under the _detectMethod those are the lines needed to get the correct HTTP method for the 'STATUS' command.
I am not really sure about what you mean by 'using a standard http request' but Codebird has already done the difficult and critical parts of the request so I see no reason why not to use the lib.
This is what I did on my test script, after a successful FINALIZE command with a 'processing_info' field response:
do{ sleep($check_after_secs); //from FINALIZE response processing_info $status_reply = $cb->media_upload(['command' => 'STATUS', 'media_id'=> $media_id //media id from INIT ])); }while($status_reply->processing_info->state != 'failed' && $status_reply->processing_info->state != 'succeeded');
//proceed on creating the tweet if processing is successful or return the error otherwise .....
Good luck! Airon
Hi Airon,
OK. i got it. Your solution is really cool. I will follow your idea to have a shot.
I didn't know codebird already has the api to update status. i will try as well.
Thank you very much for all of your solutions. you help me out.
Jarvis
From: aironlio notifications@github.com Sent: December 9, 2016 2:05 AM To: jublonet/codebird-php Cc: javayoung; Author Subject: Re: [jublonet/codebird-php] Can not post video with duration > 30 seconds (#188)
Hi javayoung,
Yes, you have to call status command after an async media/upload request until the processing_info 'state' field is = 'succeeded' to make sure that the media processing is already 100%. But I won't suggest to give a constant time frame like 5 min. It would be pointless if you use a longer time if what you only need is less than that. I think the processing time of the uploaded media depends on how big the file is. Instead, use the field 'check_after_secs' to set a delay in polling for the update. But that depends on your implementation, as in my case I set a loop with a delay until such time I get the 'succeeded' response.
As of the current writing, Codebird has already support for this on version 3.2.0 but not release yet. You can use that version if you want, or you can wait for the stable release. But, if you are really in a hurry you can check https://github.com/jublonet/codebird-php/blob/develop/src/codebird.php @versionhttps://github.com/version 3.2.0-dev line 1681 to line 1687 under the _detectMethod those are the lines needed to get the correct HTTP method for the 'STATUS' command.
[https://avatars0.githubusercontent.com/u/2606120?v=3&s=400]https://github.com/jublonet/codebird-php/blob/develop/src/codebird.php
jublonet/codebird-phphttps://github.com/jublonet/codebird-php/blob/develop/src/codebird.php github.com codebird-php - Easy access to the Twitter REST API, Collections API, Streaming API, TON (Object Nest) API and Twitter Ads API - all from one PHP library.
I am not really sure about what you mean by 'using a standard http request' but Codebird has already done the difficult and critical parts of the request so I see no reason why not to use the lib.
This is what I did on my test script, after a successful FINALIZE command with a 'processing_info' field response:
do{ sleep($check_after_secs); //from FINALIZE response processing_info $status_reply = $cb->media_upload(['command' => 'STATUS', 'media_id'=> $media_id //media id from INIT ])); }while($status_reply->processing_info->state != 'failed' && $status_reply->processing_info->state != 'succeeded');
//proceed on creating the tweet if processing is successful or return the error otherwise .....
Good luck! Airon
- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/jublonet/codebird-php/issues/188#issuecomment-265948086, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADQymlv7SEne_ZJ6hM1RzjY1-xXQ_VO8ks5rGP3VgaJpZM4K7yR5.
Thank you for the library. it works perfect with the video less than 30 seconds.
But when i post video greater than 30 seconds. it always return "Duration too long". I found one solution to add media_category=>twitter_video and i tried but I got different error "not_valid_video".
I checked the Twitter doc, it says it need to upload async. How can i use codebird to async upload the video?
Thank you very much!
Here is the code snippet I implemented. // INIT the upload
// APPEND data to the upload
// FINALIZE the upload
// Now use the media_id in a Tweet $reply = $cb->statuses_update([ 'status' => 'Twitter now accepts video uploads.', 'media_ids' => $media_id ]);