aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Miha Petkovsek <miha.petkovsek@gmail.com> 2016-07-12 18:25:00 +0200
committerGravatar Miha Petkovsek <miha.petkovsek@gmail.com> 2016-07-12 18:25:00 +0200
commit29f281d7d4232fb69fadd6931b4267b5c45fc6b3 (patch)
treecb0948a3dc8489c9c2c21e21c485abcf219a7077
parent6d079793a0d4d61834e71143ce82fc426d63dcf1 (diff)
downloadphpipam-api-clients-29f281d7d4232fb69fadd6931b4267b5c45fc6b3.tar.gz
Controller for OPTIONS can be false
-rw-r--r--php-client/class.phpipam-api.php11
1 files changed, 6 insertions, 5 deletions
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