Python tweet multiple images Twitter API
<p>I'm trying to write a script that will post two images to Twitter using the API, any idea why this doesn't work? It only posts the first image. New to this, thanks!   </p>

<pre><code>from TwitterAPI import TwitterAPI
import urllib

api = TwitterAPI('','','','')

x = []

file = open('im1.png', 'rb')
data = file.read()
r = api.request('media/upload', None, {'media': data})
media_id = r.json()['media_id']
print('UPLOAD MEDIA SUCCESS' if r.status_code == 200 else 'UPLOAD MEDIA FAILURE')
x.append(str(media_id))


file = open('im2.png', 'rb')
data1 = file.read()
r = api.request('media/upload', None, {'media': data1})
media_id = r.json()['media_id']
print('UPLOAD MEDIA SUCCESS' if r.status_code == 200 else 'UPLOAD MEDIA FAILURE')
x.append(str(media_id))


if r.status_code == 200:
    media_id = r.json()['media_id']
    r = api.request('statuses/update', {'status':'Test', 'media_ids':media_id})
    print('UPDATE STATUS SUCCESS' if r.status_code == 200 else 'UPDATE STATUS FAILURE')
</code></pre>

<p>Use tweepy (much easier);</p>

<pre><code>auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)

api = tweepy.API(auth)

Im1 = urllib.urlretrieve('http://www.meteociel.fr/cartes_obs/temp_uk.png','im1.png')

images = ('im1.png', 'im1.png')
media_ids = [api.media_upload(i).media_id_string for i in images]
api.update_status(status='msg', media_ids=media_ids)
</code></pre>

python twitter