@@ -526,9 +526,6 @@ public function set_api_controller ($controller = false) {
526
526
if ($ controller !==false ) {
527
527
$ this ->api_server_controller = strtolower ($ controller );
528
528
}
529
- else {
530
- $ this ->exception ("Invalid controller $ controller " );
531
- }
532
529
}
533
530
534
531
/**
@@ -641,10 +638,14 @@ private function curl_set_connection ($token_file) {
641
638
// Get cURL resource
642
639
$ this ->Connection = curl_init ();
643
640
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
+
644
645
// set default curl options and params
645
646
curl_setopt_array ($ this ->Connection , array (
646
647
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 ,
648
649
CURLOPT_HEADER => 0 ,
649
650
CURLOPT_VERBOSE => $ this ->debug ,
650
651
CURLOPT_TIMEOUT => 4 ,
@@ -717,7 +718,7 @@ private function curl_add_token_header ($token_file) {
717
718
$ this ->token_expires = $ token [1 ];
718
719
719
720
// is token still valid ?
720
- if ($ this ->token_expires < time ()) {
721
+ if (strlen ( $ this -> token )< 2 && $ this ->token_expires < time ()) {
721
722
// initiate authentication
722
723
$ this ->curl_authenticate ();
723
724
//save token to file
0 commit comments