亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

從 localhost 調用 Google API

從 localhost 調用 Google API

PHP
慕沐林林 2022-06-11 09:56:34
我正在嘗試從我的 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并且沒有其他信息。

奇怪但有效。


查看完整回答
反對 回復 2022-06-11
  • 1 回答
  • 0 關注
  • 131 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號