views:

43

answers:

1

Is there any google Image search API for ActionScript\MXML developers?

+1  A: 

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

Example Code

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);
}
phwd