2013-06-24 34 views

回答

3

我有類似的問題。我正在共享主機上。

我正在研究youtube API,它要求我在服務器上的主\ tmp下創建Google_Client文件夾。由於沒有發生限制,所以我進入

google-api-php-client/src/conifg.php並更改了以下行。

/***********************************Shared server therefore cannot write to server's /tmp drive therefore using an alternate location*************************************************/ 
    //'ioFileCache_directory' => (function_exists('sys_get_temp_dir') ? sys_get_temp_dir().'/Google_Client' : '/tmp/Google_Client'), 
    'ioFileCache_directory' => 'tmp/Google_Client', 

然後,我創建了下谷歌的API-PHP-客戶端tmp目錄/ src目錄

然後,我創建了下谷歌的API-PHP-客戶端Google_Client的/ src/tmp目錄

這爲我工作。希望這可以幫助。如果是,那麼標記爲答案,因爲許多人都有同樣的問題。

0

可能更容易/更好的方法來做到這一點,但我對我自己的MacBook Air:

我運行XAMPP。我使用默認的'htdocs'目錄'/ Applications/XAMPP/htdocs'。

,所以我:

  1. 去那的htdocs目錄就跑 「的mkdir tmp目錄;搭配chmod 777 TMP」

  2. 註釋掉原來ioFileCache_directory線,並加入我自己的:

    // IO類相關配置,您只需配置值 //對於配置爲ioClass的類以上

    'ioFileCache_directory'=> '/應用/ XAMPP/htdocs中的/ tmp/GoogleClient',

    /* 'ioFileCache_directory'=> (function_exists( 'sys_get_temp_dir')? sys_get_temp_dir()。 '/ Google_Client': '的/ tmp/Google_Client'),*/

就是這樣。不要以爲我必須重啓Apache。

2

對我來說,

在CONFIG.PHP line94:

變化>> '目錄'=> sys_get_temp_dir()。 '/ Google_Client'

爲>> '目錄'=> '../tmp/Google_Client'

,或者你想

+0

這對我有用。 –

11

任何其他目錄我解決了這個問題,在不改變谷歌API的任何行。 在你的PHP代碼,你探微需要指定你想要的緩存文件夾爲:

$config = new Google_Config(); 
$config->setClassConfig('Google_Cache_File', array('directory' => '../tmp/cache')); 
// Here I set a relative folder to avoid pb on permissions to a folder like /tmp that is not permitted on my mutualised host 

$client = new Google_Client($config); 
// And then, you pass the config for your GoogleClient 

它工作正常,我使用谷歌日曆服務的。

0

使用這個在PHP代碼:

$client = new Google_Client(); 
$client->setCache(new Google_Cache_File('/path/to/shared/cache')); 
+0

添加此行並未解決我的問題。但確實給了我一個新的錯誤。傳遞給Google_Cache_File :: __ construct()的參數1必須是Google_Client的一個實例,字符串給定 –

0

你是超級用戶?

su 
password 

和它的工作對我來說