]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add post to curlclient
authorEvan Prodromou <evan@status.net>
Wed, 16 Sep 2009 02:14:15 +0000 (22:14 -0400)
committerEvan Prodromou <evan@status.net>
Wed, 16 Sep 2009 02:14:15 +0000 (22:14 -0400)
lib/curlclient.php

index 99c3b6aa41077ecf4715c33b9d586653edbf47bb..c43bfb57f79e1832ed6e53048c1dee5bf2d0f19b 100644 (file)
@@ -88,8 +88,27 @@ class CurlClient extends HTTPClient
         return $this->parseResults($result);
     }
 
-    function post($url, $headers=null)
+    function post($url, $headers=null, $body=null)
     {
+        $ch = curl_init($url);
+
+        $this->setup($ch);
+
+        curl_setopt($ch, CURLOPT_POST, true);
+
+        if (!is_null($body)) {
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
+        }
+
+        if (!is_null($headers)) {
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
+        }
+
+        $result = curl_exec($ch);
+
+        curl_close($ch);
+
+        return $this->parseResults($result);
     }
 
     function setup($ch)