关于ZAKER 融媒体解决方案 合作 加入

c# – Twitter API, 带图像的推文 , 错误代码 324 “媒体 ID 验证失败 . ”

CocoaChina 11-16

我已经能够成功发布附加图像的状态更新 . 我正在使用 C#/ .NET 和一个名为 Hammock 的 REST 框架 . 首先 , 我将图像上传到 upload.twitter.com/1.1/media/upload.json 并返回 media_ids. 然后 , 我使用 media_ids 参数向 api.twitter.com/1.1/statuses/update.json 发出请求 . 这种方法很好 , 除了偶尔使用更大的图像 ,Twitter 使用以下JSON响应我的状态更新请求:

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

我尝试在媒体上传和状态更新之间等待几分钟但没有成功 . 我也发布在 Twitter 的开发者论坛上 , 但也发布在这里以防任何人经历过这个并且有任何见解 . 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

以下是 Fiddler 中的确切 ( 除了敏感值为 xxxx ’ d ) 请求 / 响应:

媒体上传请求

POST https://upload.twitter.com/1.1/media/upload.json HTTP/1.1Authorization: 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-61aefed2897eHost: upload.twitter.comContent-Length: 2399916--5fb9e9e7-25cf-49fd-b5ef-61aefed2897eContent-Disposition: form-data; name="media"; filename="d1cd395d-bebf-4733-aedc-680327ef63ec"Content-Type: image/jpeg

媒体上传响应

HTTP/1.1 200 OKcache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0content-length: 140content-type: application/json;charset=utf-8date: Tue, 16 Dec 2014 20:56:57 UTCexpires: Tue, 31 Mar 1981 05:00:00 GMTexpires: Tue, 16 Dec 2014 21:56:57 GMTlast-modified: Tue, 16 Dec 2014 20:56:57 GMTpragma: no-cacheserver: tsa_bset-cookie: lang=enset-cookie: guest_id=v1%xxxxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:56:57 UTCstatus: 200 OKstrict-transport-security: max-age=631138519x-access-level: read-writex-connection-hash: xxxxxxxxxxxx-frame-options: SAMEORIGINx-response-time: 344x-transaction: xxxxxxxxxx-xss-protection: 1; mode=block{"media_id":544959385899122689,"media_id_string":"544959385899122689","size":4311817,"image":{"w":3000,"h":2350,"image_type":"image/jpeg"}}

状态更新请求

POST https://api.twitter.com/1.1/statuses/update.json HTTP/1.1Authorization: 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-urlencodedHost: api.twitter.comContent-Length: 117status=test%20test%20test&media_ids=544959385899122689%2C544959443889557504%2C544959458036957184%2C544959545941192705

状态更新响应

HTTP/1.1 400 Bad Requestcache-control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0content-length: 73content-type: application/json;charset=utf-8date: Tue, 16 Dec 2014 20:57:49 UTCexpires: Tue, 31 Mar 1981 05:00:00 GMTlast-modified: Tue, 16 Dec 2014 20:57:49 GMTpragma: no-cacheserver: tsa_bset-cookie: lang=enset-cookie: guest_id=xxxxxx; Domain=.twitter.com; Path=/; Expires=Thu, 15-Dec-2016 20:57:49 UTCstatus: 400 Bad Requeststrict-transport-security: max-age=631138519x-access-level: read-writex-connection-hash: xxxxxxxxx-content-type-options: nosniffx-frame-options: SAMEORIGINx-response-time: 44x-transaction: xxxxxxxx-xss-protection: 1; mode=block{"errors": [ {"code":324,"message":"The validation of media ids failed."} ] }

以上内容由"CocoaChina"上传发布 查看原文
相关标签 twitterc#错误

觉得文章不错,微信扫描分享好友

扫码分享

热门推荐

查看更多内容