]> jfr.im git - z_archive/twitter.git/commitdiff
Do not POST to friendships/lookup, only users/lookup and statuses/lookup
authorMike Verdone <redacted>
Fri, 8 Aug 2014 13:43:33 +0000 (15:43 +0200)
committerMike Verdone <redacted>
Fri, 8 Aug 2014 13:43:33 +0000 (15:43 +0200)
Fixes #223

twitter/api.py
twitter/twitter_globals.py

index 2cdde6fb0661d894dbb3ecce825d052ba44be5b7..715e91d35314a1ddc2d24f9648571d3a49417c70 100644 (file)
@@ -128,6 +128,13 @@ def wrap_response(response, headers):
         res = response
     return res
 
+def method_for_uri(uri):
+    method = "GET"
+    for action in POST_ACTIONS:
+        if re.search("%s(/\d+)?$" % action, uri):
+            method = "POST"
+            break
+    return method
 
 class TwitterCall(object):
 
@@ -168,13 +175,7 @@ class TwitterCall(object):
             uriparts.append(str(kwargs.pop(uripart, uripart)))
         uri = '/'.join(uriparts)
 
-        method = kwargs.pop('_method', None)
-        if not method:
-            method = "GET"
-            for action in POST_ACTIONS:
-                if re.search("%s(/\d+)?$" % action, uri):
-                    method = "POST"
-                    break
+        method = kwargs.pop('_method', None) or method_for_uri(uri)
 
         # If an id kwarg is present and there is no id to fill in in
         # the list of uriparts, assume the id goes at the end.
index d7572ee06e2a1578109a4f727176ca4122b32542..6bcc52c533ab0ffbddbb2f349b7ce3a53598cc6d 100644 (file)
@@ -8,7 +8,7 @@
 POST_ACTIONS = [
 
     # Status Methods
-    'update', 'retweet', 'update_with_media',
+    'update', 'retweet', 'update_with_media', 'statuses/lookup',
 
     # Direct Message Methods
     'new',
@@ -30,7 +30,7 @@ POST_ACTIONS = [
     'create', 'create_all',
 
     # Users Methods
-    'lookup', 'report_spam',
+    'users/lookup', 'report_spam',
 
     # Streaming Methods
     'filter', 'user', 'site',