Php 从localhost调用googleapi

Php 从localhost调用googleapi,php,google-api,google-api-php-client,google-custom-search,Php,Google Api,Google Api Php Client,Google Custom Search,我试图从本地主机Docker容器调用GoogleCSEAPI。显然,这是不工作的原因 我已将CURLOPT\u SSL\u VERIFYPEER定义为false,以防止SSL证书验证,但没有成功 如果有人对此有任何想法,将不胜感激 我的代码: // Create the google api client $googleClient = new Google_Client(); // Set the google developer api key $googleClient->setA

我试图从本地主机Docker容器调用GoogleCSEAPI。显然,这是不工作的原因

我已将
CURLOPT\u SSL\u 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)
];

我通过将
start
参数设置为1而不是0解决了我的问题。显然,将其设置为
0
会在服务器端触发一个致命错误,导致错误400
无效值
,并且没有其他信息


奇怪但有效。

“为了防止SSL证书验证,我将CURLOPT_SSL_VERIFYPEER定义为false,但没有成功。”为什么?无论您是从本地主机还是其他地方调用,Google的SSL都应该是完全有效的。您有什么错误或具体问题?你给我们的只是“这不起作用”。我有一个错误400“无效值”。服务器不返回任何其他信息。