LoginSignup
2
2

More than 5 years have passed since last update.

Google カスタム検索API で画像検索するための設定でつまづいた

Posted at

頭にきたのでメモ

カスタム検索を作成したら画像検索項目をオンに
bl.png

<?php

require_once("./vendor/autoload.php");

$api_key = '********';
$app_name = '********';
$cx = '********';

$client = new Google_Client();
$client->setApplicationName($app_name);
$client->setDeveloperKey($api_key);

$service = new Google_Service_Customsearch($client);
$query = "歳納京子";
$param = array(
    'searchType' => 'image',
    'cx'         => $cx,
    'num'        => '10',
);

$results = $service->cse->listCse($query, $param);
var_dump($results->getItems());

PHPなら
https://github.com/google/google-api-php-client を使えば
こんな感じで書けば結果を取ってこれるはず、「だが」

設定がさっきの画像の状態だと画像検索できない!

bl2.png

上画像の状態がONだったようだ
ちょっと考えればわかったはずなのに無駄に時間を費やしてしまったので反省

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2