2016-11-07 15 views
2

私はGoogleカスタム検索APIを使用しています。画像をリクエストすると、検索結果は常に0になります。 searchType =画像を指定することにより、APIは画像だけを探し、ドキュメントによるとGoogleカスタム検索APIを使用して画像を検索していますが、検索タイプが画像の場合は0が返されます。

https://developers.google.com/custom-search/json-api/v1/reference/cse/list

:私は下のリンクでドキュメントを次のようです。

https://www.googleapis.com/customsearch/v1?key=[API_Key]&cx=017576662512468239146:omuauf_lfve&searchType=image&q=cars

と結果は以下のようになります:

{ 
"kind": "customsearch#search", 
"url": { 
    "type": "application/json", 
    "template": "https://www.googleapis.com/customsearch/v1?q={searchTerms}&num={count?}&start={startIndex?}&lr={language?}&safe={safe?}&cx={cx?}&cref={cref?}&sort={sort?}&filter={filter?}&gl={gl?}&cr={cr?}&googlehost={googleHost?}&c2coff={disableCnTwTranslation?}&hq={hq?}&hl={hl?}&siteSearch={siteSearch?}&siteSearchFilter={siteSearchFilter?}&exactTerms={exactTerms?}&excludeTerms={excludeTerms?}&linkSite={linkSite?}&orTerms={orTerms?}&relatedSite={relatedSite?}&dateRestrict={dateRestrict?}&lowRange={lowRange?}&highRange={highRange?}&searchType={searchType}&fileType={fileType?}&rights={rights?}&imgSize={imgSize?}&imgType={imgType?}&imgColorType={imgColorType?}&imgDominantColor={imgDominantColor?}&alt=json" 
}, 
"queries": { 
    "request": [ 
    { 
    "title": "Google Custom Search - cars", 
    "totalResults": "0", 
    "searchTerms": "cars", 
    "count": 10, 
    "inputEncoding": "utf8", 
    "outputEncoding": "utf8", 
    "safe": "off", 
    "cx": "017576662512468239146:omuauf_lfve", 
    "searchType": "image" 
    } 
    ] 
}, 
"searchInformation": { 
    "searchTime": 0.049329, 
    "formattedSearchTime": "0.05", 
    "totalResults": "0", 
    "formattedTotalResults": "0" 
} 
} 

私がリクエストからて、searchTypeを削除した場合、私は背中の形で結果を得る。ここ

は私のURLは次のようになります。ウェブページ。ここで何が間違っていますか?

答えて

1

カスタム検索エンジンで画像検索が無効になっている可能性があります。要求された検索タイプが無効の場合、CSE APIは0の結果を返します。

https://cse.google.com/cse/allにアクセスして、検索エンジンを開き、[画像検索]をオンに切り替えると有効になります。

+0

画像検索は現在有効です –

関連する問題