Skip to content
This repository was archived by the owner on Aug 7, 2024. It is now read-only.

Commit 4fc3458

Browse files
committed
Merge pull request #159 from udox/master
Allow post media to work with urls
2 parents ac8f187 + 6845322 commit 4fc3458

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

twitter/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,11 @@ def PostMedia(self, status, media, possibly_sensitive=None,
919919
u_status = unicode(status, self._input_encoding)
920920

921921
data = {'status': status}
922-
data['media'] = open(str(media), 'rb').read()
922+
if media.startswith('http'):
923+
data['media'] = urllib2.urlopen(media).read()
924+
else:
925+
data['media'] = open(str(media), 'rb').read()
926+
923927
if possibly_sensitive:
924928
data['possibly_sensitive'] = 'true'
925929
if in_reply_to_status_id:

0 commit comments

Comments
 (0)