@@ -526,9 +526,6 @@ public function set_api_controller ($controller = false) {
526526 if ($ controller !==false ) {
527527 $ this ->api_server_controller = strtolower ($ controller );
528528 }
529- else {
530- $ this ->exception ("Invalid controller $ controller " );
531- }
532529 }
533530
534531 /**
@@ -641,10 +638,14 @@ private function curl_set_connection ($token_file) {
641638 // Get cURL resource
642639 $ this ->Connection = curl_init ();
643640
641+ // set URL
642+ if ($ this ->api_server_controller ===false ) { $ url = $ this ->api_url .$ this ->api_app_id ."/ " ; }
643+ else { $ url = $ this ->api_url .$ this ->api_app_id .str_replace ("// " , "/ " , "/ " .$ this ->api_server_controller ."/ " .$ this ->api_server_identifiers ."/ " ); }
644+
644645 // set default curl options and params
645646 curl_setopt_array ($ this ->Connection , array (
646647 CURLOPT_RETURNTRANSFER => 1 ,
647- CURLOPT_URL => $ this -> api_url . $ this -> api_app_id . str_replace ( " // " , " / " , " / " . $ this -> api_server_controller . " / " . $ this -> api_server_identifiers . " / " ) ,
648+ CURLOPT_URL => $ url ,
648649 CURLOPT_HEADER => 0 ,
649650 CURLOPT_VERBOSE => $ this ->debug ,
650651 CURLOPT_TIMEOUT => 4 ,
@@ -717,7 +718,7 @@ private function curl_add_token_header ($token_file) {
717718 $ this ->token_expires = $ token [1 ];
718719
719720 // is token still valid ?
720- if ($ this ->token_expires < time ()) {
721+ if (strlen ( $ this -> token )< 2 && $ this ->token_expires < time ()) {
721722 // initiate authentication
722723 $ this ->curl_authenticate ();
723724 //save token to file
0 commit comments