4

画像が添付された状態の更新を正常に投稿できました。Hammock という REST フレームワークで C#/.NET を使用しています。まず、画像を 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 されていることを除いて) 要求/応答です。

メディアアップロードリクエスト

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

1 に答える 1

1

これは、画像が大きすぎることが原因です。私はちょうど同じ問題に遭遇し、大きな png (1.2MB) の jpg バージョン (300KB) を送信することで解決しました。

記載されているサイズ制限は 3MB ですが、何らかのクライアント固有のスロットリングが設定されている場合があります。

于 2015-01-28T07:40:39.267 に答える