GET media/upload (STATUS)
概述¶
STATUS
命令用于定期为媒体处理操作更新投票。STATUS
命令响应返回 succeeded
后,您可以继续下一步,通常是使用 media_id 创建推文。
请求¶
应该是带有 url 参数的 HTTP GET 请求。
注意: 此端点的域为 upload.twitter.com
响应¶
响应正文需包含 processing_info
字段,该字段提供有关当前媒体处理操作状态的信息。包含过渡流程的 state
字段:“pending”(待处理)-> “in_progress”(处理中)-> [“failed” | “succeeded”](失败 | 成功)。在状态字段设置为“succeeded”(成功)之前,不能使用 media_id 创建推文或其他实体。
资源信息¶
响应格式 | JSON |
是否需要认证? | 是(仅限用户情景) |
是否存在速率限制? | 是 |
参数¶
名称 | 必填 | 说明 | 默认值 | 示例 |
command | 必填 | 必须设置为 STATUS (区分大小写)。 |
||
media_id | 必填 | media_id 已从 INIT 命令返回。 |
示例请求¶
GET https://upload.twitter.com/1.1/media/upload.json?command=STATUS&media_id=710511363345354753
示例结果¶
// Example of an in_progress response:
{
"media_id":710511363345354753,
"media_id_string":"710511363345354753",
"expires_after_secs":3595,
"processing_info":{
"state":"in_progress", // state transition flow is pending -> in_progress -> [failed|succeeded]
"check_after_secs":10, // check for the update after 10 seconds
"progress_percent":8 // Optional [0-100] int value. Please don't use it as a replacement of "state" field.
}
}
// Example of a failed response:
{
"media_id":710511363345354753,
"media_id_string":"710511363345354753",
"processing_info":{
"state":"failed",
"progress_percent":12,
"error":{
"code":1,
"name":"InvalidMedia",
"message":"Unsupported video format"
}
}
}
// Example of a succeeded response:
{
"media_id":710511363345354753,
"media_id_string":"710511363345354753",
"expires_after_secs":3593,
"video":{
"video_type":"video/mp4"
},
"processing_info":{
"state":"succeeded",
"progress_percent":100,
}
}