是否有针对ActionScript \ MXML开发人员的Google图片搜索API?

时间:2010-06-08 17:10:52

标签: flash image api search

是否有适用于ActionScript \ MXML开发人员的Google图片搜索API?

1 个答案:

答案 0 :(得分:0)

Google Web APIs - Actionscript 3 library (v2.1)

示例代码

var googleWebSearch:GoogleWebSearch=new GoogleWebSearch();
googleWebSearch.search(txtInput.text,0,"nl");
googleWebSearch.addEventListener(GoogleApiEvent.WEB_SEARCH_RESULT,onWebResults) ;

//If you want to catch the API errors yourself:
googleWebSearch.addEventListener(GoogleAPIErrorEvent.API_ERROR,onAPIError)

private function onWebResults(e:GoogleApiEvent):void{
        var resultObject:GoogleSearchResult=e.data as GoogleSearchResult
        trace("Estimated Number of Results: "+resultObject.estimatedNumResults)
        trace("Current page index: "+resultObject.currentPageIndex)
        trace("Number of pages: "+resultObject.numPages)

        for each (var result:GoogleWebItem in resultObject.results){
                trace(result.title, result.url)
        }
}

private function onAPIError(evt:GoogleAPIErrorEvent):void{
        trace("An API error has occured: " + evt.responseDetails, "responseStatus was: " + evt.responseStatus);
}