From 29f281d7d4232fb69fadd6931b4267b5c45fc6b3 Mon Sep 17 00:00:00 2001 From: Miha Petkovsek Date: Tue, 12 Jul 2016 18:25:00 +0200 Subject: Controller for OPTIONS can be false --- php-client/class.phpipam-api.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'php-client') diff --git a/php-client/class.phpipam-api.php b/php-client/class.phpipam-api.php index 632d2e1..32798bc 100644 --- a/php-client/class.phpipam-api.php +++ b/php-client/class.phpipam-api.php @@ -526,9 +526,6 @@ class phpipam_api_client { if($controller!==false) { $this->api_server_controller = strtolower($controller); } - else { - $this->exception("Invalid controller $controller"); - } } /** @@ -641,10 +638,14 @@ class phpipam_api_client { // Get cURL resource $this->Connection = curl_init(); + // set URL + if($this->api_server_controller===false) { $url = $this->api_url.$this->api_app_id."/"; } + else { $url = $this->api_url.$this->api_app_id.str_replace("//", "/", "/".$this->api_server_controller."/".$this->api_server_identifiers."/"); } + // set default curl options and params curl_setopt_array($this->Connection, array( CURLOPT_RETURNTRANSFER => 1, - CURLOPT_URL => $this->api_url.$this->api_app_id.str_replace("//", "/", "/".$this->api_server_controller."/".$this->api_server_identifiers."/"), + CURLOPT_URL => $url, CURLOPT_HEADER => 0, CURLOPT_VERBOSE => $this->debug, CURLOPT_TIMEOUT => 4, @@ -717,7 +718,7 @@ class phpipam_api_client { $this->token_expires = $token[1]; // is token still valid ? - if ($this->token_expires < time()) { + if (strlen($this->token)<2 && $this->token_expires < time()) { // initiate authentication $this->curl_authenticate (); //save token to file -- cgit v1.2.3