]> jfr.im git - z_archive/twitter.git/commitdiff
add doc to send tweets with images in README + consolidate api.py/README
authorRouxRC <redacted>
Tue, 22 Jul 2014 22:25:25 +0000 (00:25 +0200)
committerRouxRC <redacted>
Tue, 22 Jul 2014 22:25:25 +0000 (00:25 +0200)
README
twitter/api.py

diff --git a/README b/README
index eefdf2bccccc7cd092c8641adfeeedba310c026e..804cbdf2db9b9e161cb758699beb24bc2eadb3da 100644 (file)
--- a/README
+++ b/README
@@ -127,6 +127,15 @@ t.users.lookup(screen_name=','.join(A_LIST_OF_100_SCREEN_NAMES), _timeout=1)
 # detects whether GET or POST should be used, Nevertheless
 # to force a particular method, use `_method`
 t.statuses.oembed(_id=1234567890, _method='GET')
+
+# 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:
+with open("example.png", "rb") as imagefile:
+    params = {"media[]": imagefile.read(), "status": "PTT"}
+t.statuses.update_with_media(**params)
+# - or by sending a base64 encoded image:
+params = {"media[]": base64_image, "status": "PTT", "_base64": True}
+t.statuses.update_with_media(**params)
 ```
 
 Searching Twitter::
index 28979b581de4779d5cea3f1f226a2c20c34aa47f..bed62754eaed01a0b670965dbde6db378e5a5ed0 100644 (file)
@@ -330,6 +330,21 @@ class Twitter(TwitterCall):
             screen_name=','.join(A_LIST_OF_100_SCREEN_NAMES), \
             _timeout=1)
 
+        # Overriding Method: GET/POST
+        # you should not need to use this method as this library properly
+        # detects whether GET or POST should be used, Nevertheless
+        # to force a particular method, use `_method`
+        t.statuses.oembed(_id=1234567890, _method='GET')
+
+        # 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:
+        with open("example.png", "rb") as imagefile:
+            params = {"media[]": imagefile.read(), "status": "PTT"}
+        t.statuses.update_with_media(**params)
+        # Or by sending a base64 encoded image:
+        params = {"media[]": base64_image, "status": "PTT", "_base64": True}
+        t.statuses.update_with_media(**params)
+
 
 
     Searching Twitter::