Code to Automatically Post Images To My Twitter Account via Python Script -


i want post images programmatically on own (not other peoples') twitter account. end, tried using tweepy library -- have method called api.update_with_media('the image') not work.

it seems twitter has deprecated method: ...statuses/update_with_media (sorry truncated html -> i'm new here, won't let me post many links)

twitter instructs use instead: ...public/uploading-media

basically, 2-step method. step 1) upload media , id in json step 2) use id update status

both of these steps require authentication. problem twitter libraries, (which can found here twitter-libraries) don't support new method. have simple 1 before in documentation.

it seems possibly 1 fixed it, docs didn't updated (i didn't play -- @ point decided contract out). can found here.

it seems options are:

1) build code scratch, including a) oauth (breakable, complex) b) update status script (re-writing code libraries have)

2) same above use generic oauth library

3) find library supports new upload method -- there may 1 in list, involve reading through documentation , testing, or

4) other idea didn't think of

i made sure works text updates -- replace api.update_with_media(image) api.update_status(status='hey').

for reference, here's code i'm using:

` import urllib import tweepy

@app.route('/') def testing():

consumer_key = '---' consumer_secret = '---' access_token = '---' access_token_secret = '---'  #oauth process, using keys , tokens auth = tweepy.oauthhandler(consumer_key, consumer_secret) auth.set_access_token(access_token, access_token_secret)  #creation of actual interface, using authentication api = tweepy.api(auth)  #should encode image - tried several different way image = urllib.urlopen('image-url')  try:     api.update_with_media(image) except exception, e:     print e  return "ok" 

`

i solved using library instead: http://geduldig.github.io/twitterapi/examples.html


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -