]> jfr.im git - z_archive/twitter.git/commitdiff
Add POST method for follow and leave actions
authorMike Verdone <redacted>
Fri, 13 Feb 2009 18:26:34 +0000 (11:26 -0700)
committerMike Verdone <redacted>
Fri, 13 Feb 2009 18:26:34 +0000 (11:26 -0700)
twitter/api.py

index 2fa4e19c3d65a1adf28d0894f5f36f16481f533c..628120f568025f005702a417d39e9849fb6dfd7f 100644 (file)
@@ -22,6 +22,11 @@ class TwitterError(Exception):
     """
     pass
 
+# These actions require POST http requests instead of GET
+_POST_ACTIONS = [
+    "create", "update", "destroy", "new", "follow", "leave",
+    ]
+
 class TwitterCall(object):
     def __init__(self, username, password, format, domain, uri=""):
         self.username = username
@@ -38,12 +43,11 @@ class TwitterCall(object):
                 self.uri + "/" + k)
     def __call__(self, **kwargs):
         method = "GET"
-        if (self.uri.endswith('new') 
-            or self.uri.endswith('update')
-            or self.uri.endswith('create')
-            or self.uri.endswith('destroy')):
-            method = "POST"
-        
+        for action in _POST_ACTIONS:
+            if self.uri.endswith(action):
+                method = "POST"
+                break
+            
         encoded_kwargs = urlencode(kwargs.items())
         argStr = ""
         if kwargs and (method == "GET"):