私のMacは最近 "retired"なので、Windows上のUbuntuインストールにRails 2.3.8アプリを移植しました。私のGoogleカスタム検索(CSE)を使用して画像検索を行うと、結果は得られません。画像検索結果が返されません
有効なAPIキーと固有のカスタム検索IDがあります。これは、CSEを使用して通常の「ウェブ」検索を実行すると結果が得られるためです。私はまた、毎日のリクエスト制限の範囲内にあります。また、公開されている構文が変更されていないことを確認するためにAPIリファレンスを再確認しました。
は、私は、次のリクエストを発行しています:
result_count=10
query='apple'
1)ウェブ検索(利回り結果) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
type=''
url="https://www.googleapis.com/customsearch/v1?key=#{ENV['GOOGLE_KEY']}&cx=#{ENV['GOOGLE_SEARCH_ID']}#{type}&alt=json&num=#{result_count}&q=#{query}"
RESULT =>予想されたように、10の項目/とJSON形式の文字列に関係なく
2)イメージ検索(NO結果をもたらすO Fクエリ) - - - - - - - - - - - - - - - - - 以下に示す商品/結果と
type='&searchType=image'
url="https://www.googleapis.com/customsearch/v1?key=#{ENV['GOOGLE_KEY']}&cx=#{ENV['GOOGLE_SEARCH_ID']}#{type}&alt=json&num=#{result_count}&q=#{query}"
RESULT => JSON形式の文字列、:
{
"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 - apple",
"totalResults": "0",
"searchTerms": "apple",
"count": 10,
"inputEncoding": "utf8",
"outputEncoding": "utf8",
"safe": "off",
"cx": "my_private_cx_id",
"searchType": "image"
}
]
},
"searchInformation": {
"searchTime": 0.023136,
"formattedSearchTime": "0.02",
"totalResults": "0",
"formattedTotalResults": "0"
}
}
私がアプリを移植するまで、画像検索はうまく機能しませんでした。私は何が欠けているのか分かりませんが、軽微な見落としがあると思われます。
良いものです。ありがとう、レダン - 私は何とかそれを逃した。すべて今働いている。乾杯。 – frank