簡體   English   中英

Twitter API,圖片推文,錯誤代碼324“媒體ID驗證失敗。”

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

我已經能夠成功發布附加圖像的狀態更新。 我正在使用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.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

媒體上傳響應

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"}}

狀態更新請求

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

狀態更新響應

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."}]}

這是圖像太大的結果。 我剛剛遇到了同樣的問題,並通過發送一個大的png(它是1.2MB)的jpg版本(300KB)來解決它。

規定的大小限制為3MB,但它們可能具有某種特定於客戶端的限制。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM