Преглед на файлове

Update metodo webservice

Guillermo Espinoza преди 7 години
родител
ревизия
657599a288
променени са 1 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 8 1
      Services/Webservice.php

+ 8 - 1
Services/Webservice.php

@@ -87,12 +87,19 @@ class Webservice
     /**
      * @param string $url
      * @param string $method
+     * @param array $data
      * 
      * @return HttpResponse
      */
-    public function makeRequest($url, $method = HttpRequestInterface::METHOD_GET)
+    public function makeRequest($url, $method = HttpRequestInterface::METHOD_GET, $data = array())
     {
         $request = new HttpRequest($method, $url);
+        $headers = array();
+        if (!empty($data)) {
+            $headers[] = 'Content-Type: application/x-www-form-urlencoded';
+            $request->setContent(http_build_query($data));
+        }
+        $request->setHeaders($headers);
         $response = new HttpResponse();
         $this->httpClient->send($request, $response);