Skip to content

Instantly share code, notes, and snippets.

@GOROman
Last active January 1, 2016 23:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GOROman/8214880 to your computer and use it in GitHub Desktop.
Save GOROman/8214880 to your computer and use it in GitHub Desktop.
環境: Windows7 64bit twurlでTwitterに画像を添付したいだけなのに ”403 Forbidden” でどうにも出来ないのでキレそう。。。  ⇒ 解決
Cygwinにしたら解決しました・・・
$ ruby -v
ruby 1.9.3p448 (2013-06-27) [x86_64-cygwin]
$ twurl -v
0.9.1
$ twurl -d 'status=HELLO KARAAGE!' -X POST "/1.1/statuses/update_with_media.json" --file "TEST.png" --file-field "media[]" -t
@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

--base64 で BASE64にしてもNG

@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

updateでつぶやくのはうまくいってるので認証自体はできている。

https://twitter.com/GOROman/status/418588589107081216

@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

https://dev.twitter.com/docs/uploading-media

" we recommend testing with Twurl."
とか書いてあるのに全然動かない件・・・。

@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

Cygwinにしたら出来た・・・。死のう。

@GOROman
Copy link
Author

GOROman commented Jan 2, 2014

パケットの中身

POST /1.1/statuses/update_with_media.json HTTP/1.1
Accept: /
User-Agent: OAuth gem v0.4.7
Content-Type: multipart/form-data, boundary="00Twurl315658315140108384lruwT99"
Authorization: OAuth oauth_body_hash="...",oauth_consumer_key="...", oauth_nonce="...", oauth_signature="...", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1388637706", oauth_token="...", oauth_version="1.0"
Connection: close
Host: api.twitter.com
Content-Length: 535

--00Twurl315658315140108384lruwT99
Content-Disposition: form-data; name="status"

HELLO KARAAGE!
--00Twurl315658315140108384lruwT99
Content-Disposition: form-data; name="media[]"; filename="TEST.png"
Content-Type: application/octet-stream
Content-Transfer-Encoding: base64

iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c\n6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAwSURB\nVDhPlcexDQAwCMAw/j+XB8ruJarkxfP2j08++eSTTz755JNPPvnkk08++bBz\nNrbxENvBoHQAAAAASUVORK5CYII=

--00Twurl315658315140108384lruwT99--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment