POST media/upload エンドポイントを使用する場合には、理解しておかなければならない重要な概念がいくつかあります。 OAuth を使ってメディアをアップロードするのは少し複雑なので、エンドポイントを使った動作サンプルと覚えておかなければならないことをこのページにまとめます。
Guide to Uploading MediaThere are a few important concepts to understand when using the POST media/upload endpoint. Uploading media with OAuth can be a bit tricky, so we’ve outlined some things to keep in mind as well as a working sample of how to use this endpoint here. |
oauth_* パラメータのみが使用されます。
application/octet-stream).
Keep in mind
|
As of Twurl v0.9.0 (see our command-line Twurl tool) support for calling Twitter’s v1.1 REST API with a multipart message for the POST media/upload endpoint now exists. Use this example as a great way to debug your own code. Twitter ライブラリの多くはあなたに代わってこのPOSTを正しく処理するメソッドを実装しているので、覚えておいてください。
-t オプションを使用すると、Twitter APIへPOSTされたリクエストと応答の全トレースが表示されます。
twurl -H upload.twitter.com -X POST "/1.1/media/upload.json" --file "/path/to/media.jpg" --file-field "media"
{
"media_id": 553656900508606464,
"media_id_string": "553656900508606464",
"size": 998865,
"image": {
"w": 2234,
"h": 1873,
"image_type": "image/jpeg"
}
}
Example of media/uploadAs of Twurl v0.9.0 (see our command-line Twurl tool) support for calling Twitter’s v1.1 REST API with a multipart message for the POST media/upload endpoint now exists. Use this example as a great way to debug your own code. Note that many of the Twitter Libraries include methods that will handle this POST correctly for you. Using the
{
"media_id": 553656900508606464,
"media_id_string": "553656900508606464",
"size": 998865,
"image": {
"w": 2234,
"h": 1873,
"image_type": "image/jpeg"
}
}
|