From 7b3ac62f7302d60c3e467eca6c3324aeb9c3e825 Mon Sep 17 00:00:00 2001 From: jbousquie Date: Thu, 24 Nov 2016 14:07:23 +0100 Subject: [PATCH] ajout PostURL() --- admin/client_http.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/admin/client_http.php b/admin/client_http.php index 12164f3..430cad3 100644 --- a/admin/client_http.php +++ b/admin/client_http.php @@ -2,7 +2,7 @@ // Client HTTP require_once 'HTTP/Request2.php'; -// fonction GetURL() : renvoie le contenu d'une réponse à un GET http +// Fonction GetURL() : renvoie le contenu d'une réponse à un GET http // renvoie une string contenant le corps de la réponse Function GetURL($url) { $body = ""; @@ -18,4 +18,22 @@ Function GetURL($url) { } return $body; }; + +// Fonction PostURL() : émet un POST http sur l'url +// paramètre : string $url et $param, un array de paramètres du POST +Function PostURL($url, $params) { + $body = ""; + $http = new HTTP_Request2( $url, HTTP_Request2::METHOD_POST); + $http->addPostParameter($params); + try { + $response = $http->send(); + if (200 == $response->getStatus()) { + $body = $response->getBody(); + } + } + catch (HTTP_Request2_Exception $ex) { + echo $ex; + } + return $body; +}; ?> \ No newline at end of file