2016-02-02 42 views
0

我想在我的網站上使用「google-api-php-client」類(並且我手動上傳到我的子文件夾博客中的主機)試圖用「set_include_path」函數動態地包含它。但是,在應用require_once時,我的代碼停在那裏,所以我沒有包含它們。我展示了我爲此測試的代碼:動態地通過set_include_path包含Google Api客戶端庫類

或者,您可以在代碼中動態地設置相同的ini指令。 set_include_path(get_include_path()path_separator'/ path/to/google-api-php-client/src');

我的代碼:

// 1st try with the full path to the folder classes Google Api: 
set_include_path (get_include_path(). path_separator. '/home/u140888/domains/segurosq.com/public_html/blog/google-api-php-client/src')) 

// 2nd try with the route from the subfolder Blog to Google Api classes: 
set_include_path (get_include_path() path_separator '/ blog/google-api-php-client/src'..); 

// 3rd attempt the route from the folder with Google Api classes: 
set_include_path (get_include_path() path_separator '/ google-api-php-client/src'..); 

// This line require_once my code stops and you can not instantiate the class within Client.php because it has not been added successfully: 
require_once 'Google/Client.php'; 

我在include_path參數設置php.ini中進入我的cPanel主機或沒有成功託管服務提供商嘗試這樣做甚至直接。

回答

0

如果你的文件是/home/u140888/domains/segurosq.com/public_html/blog/試試這個:

通過set_include_path('/home/u140888/domains/segurosq.com/public_html/blog/google -api-php-client /'。PATH_SEPARATOR。get_include_path());

require_once('google-api-php-client/autoload.php');

$ client = new Google_Client(); ...

0

現在我很好走。問題在於我沒有爲我的PHP 5.2版本使用正確版本的Google Api文件。現在我可以無縫地實現這些類的實例。感謝您的幫助,我真的很感激。 :-)

相關問題