# Send a tweet with an image included (or set your banner or logo similarily)
# by just reading your image from the web or a file in a string:
+# Note that the text sent as status along with the picture must be unicode.
+status = u"PTT ★" # or with python 3: status = "PTT ★"
with open("example.png", "rb") as imagefile:
- params = {"media[]": imagefile.read(), "status": "PTT"}
+ params = {"media[]": imagefile.read(), "status": status}
t.statuses.update_with_media(**params)
# Or by sending a base64 encoded image:
-params = {"media[]": base64_image, "status": "PTT", "_base64": True}
+params = {"media[]": base64_image, "status": status, "_base64": True}
t.statuses.update_with_media(**params)
```
headers['Content-Type'] = \
'multipart/form-data; boundary=%s' % BOUNDARY
+ if sys.version_info[:2] == (2, 7):
+ uriBase = uriBase.encode("utf-8")
+ for k in headers:
+ headers[k.encode('utf-8')] = headers.pop(k)
+
req = urllib_request.Request(uriBase, body, headers)
return self._handle_response(req, uri, arg_data, _timeout)
# Send a tweet with an image included (or set your banner or logo similarily)
# by just reading your image from the web or a file in a string:
+ # Note that the text sent as status along with the picture must be unicode.
+ status = u"PTT ★" # or with python 3: status = "PTT ★"
with open("example.png", "rb") as imagefile:
- params = {"media[]": imagefile.read(), "status": "PTT"}
+ params = {"media[]": imagefile.read(), "status": status}
t.statuses.update_with_media(**params)
# Or by sending a base64 encoded image:
- params = {"media[]": base64_image, "status": "PTT", "_base64": True}
+ params = {"media[]": base64_image, "status": status, "_base64": True}
t.statuses.update_with_media(**params)