4 # https://github.com/python-twitter-tools/twitter
11 # if needed for development, just hardcode
17 with fileinput
.input(files
=(os
.environ
.get('HOME') + os
.sep
+ '.rainbow_oauth')) as f
:
18 # ok, this is dumb, but it works
21 oauth_token
= line
.rstrip()
24 oauth_secret
= line
.rstrip()
26 CONSUMER_KEY
= 'hJHyPhuU7nSVHrKTVsGVDM4Lw'
27 CONSUMER_SECRET
= '8UCYePqc1y9DY6mg0yQzLoTuq57AIysype2Si63714uACGMCbO'
29 t
= Twitter(auth
=OAuth(oauth_token
, oauth_secret
, CONSUMER_KEY
, CONSUMER_SECRET
))
47 with
open(image_path
, "rb") as imagefile
:
48 imagedata
= imagefile
.read()
49 t_upload
= Twitter(domain
='upload.twitter.com',
50 auth
=OAuth(oauth_token
, oauth_secret
, CONSUMER_KEY
, CONSUMER_SECRET
))
51 id_img
= t_upload
.media
.upload(media
=imagedata
)["media_id_string"]
54 t_upload
.media
.metadata
.create(media_id
=id_img
, text
=alt
)
57 t
.statuses
.update(status
=tweet_text
, media_ids
=id_img
)
59 t
.statuses
.update(status
=tweet_text
)