简体   繁体   English

Twitter API,图片推文,错误代码324“媒体ID验证失败。”

[英]Twitter API, Tweets with Images, Error Code 324 “The validation of media ids failed.”

I have been able to successfully post status updates with images attached. 我已经能够成功发布附加图像的状态更新。 I am using C#/.NET with a REST framework called Hammock. 我正在使用C#/ .NET和一个名为Hammock的REST框架。 First, I upload the images to upload.twitter.com/1.1/media/upload.json and get media_ids back. 首先,我将图像上传到upload.twitter.com/1.1/media/upload.json并返回media_ids。 Then, I make a request to api.twitter.com/1.1/statuses/update.json with the media_ids parameter. 然后,我使用media_ids参数向api.twitter.com/1.1/statuses/update.json发出请求。 This works fine except that occassionally, with larger images, Twitter responds to my status update request with the following JSON: 这种方法很好,除了偶尔使用更大的图像,Twitter使用以下JSON响应我的状态更新请求:

{"errors":[{"code":324,"message":"The validation of media ids failed."}]}

I have tried waiting several minutes between the time of media upload and status update with no success. 我尝试在媒体上传和状态更新之间等待几分钟但没有成功。 I have also posted on Twitter's developer forums, but posting here as well in case anyone has experienced this and has any insight. 我也发布在Twitter的开发者论坛上,但也发布在这里以防任何人经历过这个并且有任何见解。 https://twittercommunity.com/t/the-validation-of-media-ids-failed-error-code-324/29304 I don't see "324" anywhere in Twitter's API documentation, especially here: https://dev.twitter.com/overview/api/response-codes https://twittercommunity.com/t/the-validation-of-media-ids-failed-error-code-324/29304我在Twitter的API文档中没有看到“324”,特别是在这里: https:// dev.twitter.com/overview/api/response-codes

Here are the exact (except for sensitive values being xxxx'd out) requests/responses seen in Fiddler: 以下是Fiddler中的确切(除了敏感值为xxxx'd)请求/响应:

Media Upload Request 媒体上传请求

POST https://upload.twitter.com/1.1/media/upload.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="xxxxxxxxxxx",oauth_nonce="xxxxxxxxxxx",oauth_signature="xxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1418763417",oauth_token="xxxxxxxxxx",oauth_version="1.0a"
Content-Type: multipart/form-data; boundary=5fb9e9e7-25cf-49fd-b5ef-61aefed2897e
Host: upload.twitter.com
Content-Length: 2399916

--5fb9e9e7-25cf-49fd-b5ef-61aefed2897e
Content-Disposition: form-data; name="media"; filename="d1cd395d-bebf-4733-aedc-680327ef63ec"
Content-Type: image/jpeg

Media Upload Response 媒体上传响应

HTTP/1.1 200 OK
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 140
content-type: application/json;charset=utf-8
date: Tue, 16 Dec 2014 20:56:57 UTC
expires: Tue, 31 Mar 1981 05:00:00 GMT
expires: Tue, 16 Dec 2014 21:56:57 GMT
last-modified: Tue, 16 Dec 2014 20:56:57 GMT
pragma: no-cache
server: tsa_b
set-cookie: lang=en
set-cookie: guest_id=v1%xxxxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:56:57   UTC
status: 200 OK
strict-transport-security: max-age=631138519
x-access-level: read-write
x-connection-hash: xxxxxxxxxxx
x-frame-options: SAMEORIGIN
x-response-time: 344
x-transaction: xxxxxxxxx
x-xss-protection: 1; mode=block

{"media_id":544959385899122689,"media_id_string":"544959385899122689","size":4311817,"image":{"w":3000,"h":2350,"image_type":"image\/jpeg"}}

Status Update Request 状态更新请求

POST https://api.twitter.com/1.1/statuses/update.json HTTP/1.1
Authorization: OAuth oauth_consumer_key="xxxxxxxxxx",oauth_nonce="xxxxx",oauth_signature="xxxxxxxxxxxx",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1418763469",oauth_token="xxxxxxxxxxx",oauth_version="1.0a"
Content-Type: application/x-www-form-urlencoded
Host: api.twitter.com
Content-Length: 117

status=test%20test%20test&media_ids=544959385899122689%2C544959443889557504%2C544959458036957184%2C544959545941192705

Status Update Response 状态更新响应

HTTP/1.1 400 Bad Request
cache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0
content-length: 73
content-type: application/json;charset=utf-8
date: Tue, 16 Dec 2014 20:57:49 UTC
expires: Tue, 31 Mar 1981 05:00:00 GMT
last-modified: Tue, 16 Dec 2014 20:57:49 GMT
pragma: no-cache
server: tsa_b
set-cookie: lang=en
set-cookie: guest_id=xxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:57:49 UTC
status: 400 Bad Request
strict-transport-security: max-age=631138519
x-access-level: read-write
x-connection-hash: xxxxxxxx
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
x-response-time: 44
x-transaction: xxxxxxx
x-xss-protection: 1; mode=block

{"errors":[{"code":324,"message":"The validation of media ids failed."}]}

This is a result of the image being too large. 这是图像太大的结果。 I just ran in to the same issue, and resolved it by sending along a jpg version (300KB) of a largeish png (it was 1.2MB). 我刚刚遇到了同样的问题,并通过发送一个大的png(它是1.2MB)的jpg版本(300KB)来解决它。

The stated size limit is 3MB, but they might have some kind of client-specific throttling in place. 规定的大小限制为3MB,但它们可能具有某种特定于客户端的限制。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 得到错误:“ viewState MAC验证失败。” - Getting error: “Validation of viewState MAC failed.” 使用Twitter API发布推文时出错 - Error in Posting Tweets using twitter api 使用 Twitter API 获取受保护的推文 - Get protected tweets with Twitter API 通过Twitter API阅读推文? - read tweets via Twitter API? 错误:“属性'ContentControl'的代码生成失败。”(C#) - Error: “Code generation for property 'ContentControl' failed.” (C#) Windows Azure结束连接并返回324错误代码 - Windows Azure ends connection and returns a 324 error code AuthenticationFailed 的 Azure AD 授权错误:IDX10501:签名验证失败。 无法匹配“孩子” - Azure AD Authorize Error of AuthenticationFailed: IDX10501: Signature validation failed. Unable to match 'kid' 显然是随机错误:“防伪令牌验证失败。防伪 cookie 令牌和请求令牌不匹配。” - Apparently Random Error: "Antiforgery token validation failed. The antiforgery cookie token and request token do not match." 事件中心错误:放置令牌失败。 状态码:401,状态描述:ExpiredToken - Event Hub Error: Put token failed. status-code: 401, status-description: ExpiredToken Azure b2c 错误:IDX10501:签名验证失败。 无法匹配密钥:孩子:'gLv****************' - Azure b2c error: IDX10501: Signature validation failed. Unable to match key: kid: 'gLv****************'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM