谷歌图片搜索没有返回任何结果


ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require __DIR__.'/vendor/autoload.php';
define('GOOGLE_API_KEY', 'MY-KEY');
define('GOOGLE_CX', 'CX-ID');
$client = new Google_Client();
$client->setApplicationName("My Project Name");
$client->setDeveloperKey(GOOGLE_API_KEY);
$search = new Google_Service_Customsearch($client);
$params = array(
    'fileType' => 'png',
    'imgSize' => 'large',
    'searchType' => 'image',
    'filter' => 1,
    'num' => 10,
    'googlehost' => 'google.co.nz',
    'cx' => GOOGLE_CX
);
$q = 'lenovo logo transparent';
try {
    $results = $search->cse->listCse($q, $params);
    echo '<pre>'.print_r($results,1).'</pre>';
} catch (Google_ServiceException $e) {
    $error = $e->getMessage();
} catch (Google_Exception $e) {
    $error = $e->getMessage();
}
echo 'Done!';

. .不返回结果,也不返回任何错误,只是回显Done。我哪里做错了?

证明API的referrer设置不正确。

相关内容

  • 没有找到相关文章

最新更新