diff --git a/src/FusionDirectory/Rest/WebServiceCall.php b/src/FusionDirectory/Rest/WebServiceCall.php index ad8ff91d9c9bf3197fa9569b9444eb23a4aa4548..dcd6d512147bf821224cf84e2cd1ba636562e261 100644 --- a/src/FusionDirectory/Rest/WebServiceCall.php +++ b/src/FusionDirectory/Rest/WebServiceCall.php @@ -33,6 +33,11 @@ class WebServiceCall { $this->ch = !empty($URL) ? curl_init($URL) : curl_init($this->URL); + // We require to set a proper http_agent + $os = PHP_OS; + $phpVersion = PHP_VERSION; + $customUserAgent = "FusionDirectory/Integrator ($os; PHP $phpVersion; https://www.fusiondirectory.org) WebserviceLib"; + // Manage a trick to perform refresh on user DN if (!empty($data) && array_key_exists('refreshUser', $data)) { // Empty array is required to update the user dn without passing information, json_encode will transform it to {} @@ -49,6 +54,7 @@ class WebServiceCall case 'patch' : curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); curl_setopt($this->ch, CURLOPT_POSTFIELDS, json_encode($this->data)); + curl_setopt($this->ch, CURLOPT_USERAGENT, $customUserAgent); break; case 'get' : // No curl_setopt required @@ -56,13 +62,16 @@ class WebServiceCall case 'put': curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($this->ch, CURLOPT_POSTFIELDS, json_encode($this->data)); + curl_setopt($this->ch, CURLOPT_USERAGENT, $customUserAgent); break; case 'delete': curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); + curl_setopt($this->ch, CURLOPT_USERAGENT, $customUserAgent); break; case 'post': curl_setopt($this->ch, CURLOPT_POST, TRUE); curl_setopt($this->ch, CURLOPT_POSTFIELDS, json_encode($this->data)); + curl_setopt($this->ch, CURLOPT_USERAGENT, $customUserAgent); break; } } @@ -103,9 +112,15 @@ class WebServiceCall $ch = curl_init($this->URL); + // We require to set a proper http_agent + $os = PHP_OS; + $phpVersion = PHP_VERSION; + $customUserAgent = "FusionDirectory/Integrator ($os; PHP $phpVersion; https://www.fusiondirectory.org) WebserviceLib"; + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($loginData)); curl_setopt($ch, CURLOPT_POST, TRUE); + curl_setopt($ch, CURLOPT_USERAGENT, $customUserAgent); $response = curl_exec($ch); $this->handleCurlError($ch);