我正在嘗試從我的 localhost Docker 容器中調用 Google CSE Api。顯然,正因為如此,這不起作用。我已定義CURLOPT_SSL_VERIFYPEER為 false 以防止 SSL 證書驗證,但沒有成功。如果有人對此有任何想法,我們將不勝感激。我的代碼:// Create the google api client$googleClient = new Google_Client();// Set the google developer api key$googleClient->setApplicationName('GoogleApi_Search');$googleClient->setDeveloperKey(self::GOOGLE_SEARCH_API_KEY);// for development purposes$guzzleConfig = [ 'curl' => [CURLOPT_SSL_VERIFYPEER => false], 'headers' => ['Referer' => 'localhost:8080'],];$guzzleClient = new Client($guzzleConfig);$googleClient->setHttpClient($guzzleClient);// The google custom search service client$this->googleService = new Google_Service_Customsearch($googleClient);// Define the search parameters$this->searchParams = [ 'cx' => self::GOOGLE_SEARCH_ENGINE_ID, // Custom search engine identifier 'gl' => 'en', // Location of results 'lr' => 'lang_en', // Language of results 'num' => 10, // Number of results (max. 10) 'start' => 0, // The current index (max. 10)];
1 回答

慕村9548890
TA貢獻1884條經驗 獲得超4個贊
start
我通過將參數設置為1而不是0解決了我的問題。顯然,將其設置為在服務器端0
觸發致命錯誤,導致錯誤400 Invalid Value
并且沒有其他信息。
奇怪但有效。
- 1 回答
- 0 關注
- 131 瀏覽
添加回答
舉報
0/150
提交
取消