]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Twitter-compatible API - RESTfulness checks as per Twitter
authorzach <zach@controlyourself.ca>
Tue, 19 Aug 2008 21:49:23 +0000 (17:49 -0400)
committerzach <zach@controlyourself.ca>
Tue, 19 Aug 2008 21:49:23 +0000 (17:49 -0400)
darcs-hash:20080819214923-462f3-83ab492cb93c1ba643beb70853578cbd7ac35d61.gz

actions/twitapiaccount.php
actions/twitapifriendships.php
actions/twitapistatuses.php

index 716ddd1543a3d3c22b7fbb8c3bc95131a68ef121..3a9b8ba3e2f60db4abc96211c6b6821dc3233a20 100644 (file)
@@ -61,6 +61,11 @@ class TwitapiaccountAction extends TwitterapiAction {
        function update_location($args, $apidata) {
                parent::handle($args);
 
+               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+                       exit();
+               }
+
                $location = trim($this->arg('location'));
 
                if (!is_null($location) && strlen($location) > 255) {
index ae15d171e7c95e0233b2f26a0bc5484f477934b8..3cc925c3690bcd2ef29c00961e70e93418b877fd 100644 (file)
@@ -40,6 +40,11 @@ class TwitapifriendshipsAction extends TwitterapiAction {
        function create($args, $apidata) {
                parent::handle($args);
 
+               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+                       exit();
+               }
+
                $id = $apidata['api_arg'];
 
                $other = $this->get_user($id);
@@ -98,6 +103,12 @@ class TwitapifriendshipsAction extends TwitterapiAction {
        
        function destroy($args, $apidata) {
                parent::handle($args);
+               
+               if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) {
+                       $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']);
+                       exit();
+               }
+               
                $id = $apidata['api_arg'];
 
                # We can't subscribe to a remote person, but we can unsub
index 4ad2766c0a439ccdf5ac015fe80d4bcc68e943ba..2f95d90c9d34086da64201111d873cab4cde82e6 100644 (file)
@@ -374,6 +374,11 @@ class TwitapistatusesAction extends TwitterapiAction {
 
                parent::handle($args);
 
+               if ($_SERVER['REQUEST_METHOD'] != 'POST') {
+                       $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']);
+                       exit();
+               }
+
                $user = $apidata['user'];
                $status = $this->trimmed('status');
                $source = $this->trimmed('source');