前提・実現したいこと
ツイッターAPiを使って画像呟きをしたい。
発生している問題・エラーメッセージ
画像をつぶやくコードを作りましたが、ステータスが200(エラーが起きていない)状態で処理が終了し、何もつぶやかれない。
該当のソースコード
python
1#tweet with image 2from requests_oauthlib import OAuth1Session 3from API_Study import personal_information as inf 4 5# twitter contribution URL 6url = "https://api.twitter.com/1.1/statuses/update.json" 7url_media = "https://upload.twitter.com/1.1/media/upload.json" 8 9# twitter context 10 11files = { "status": "Hello, World!afa","media": open("image/test.png", "rb")} 12 13#OAuth contribution with POST method 14 15#CKコンシューマーキー 16#CSコンシューマーシークレット 17#ATアクセストークン 18#AS アクセストークンシークレット 19twitter = OAuth1Session(inf.CK, inf.CS, inf.AT, inf.AS) 20req = twitter.post(url_media, files = files) 21 22# respons confirmation 23if req.status_code == 200: 24 print("OK") 25else: 26 print("Error:" + str(req.status_code))
試したこと
APIを通して呟きを反映させることはすでにできています。
ツイッターAPIのリファレンスを読もうとしましたが、どう読めばいいかわからない状態です。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/24 10:40