1 Reply Latest reply on Oct 4, 2011 2:19 AM by Chaos7703

    Performing Google Product search in Flex 4.5

    capionoO

      I do I perform a google product search within my mobile application?

      I tried this:

      //WEB SEARCH FUNCTIONS

      private function doWebSearch():void{

      //currentWebResultStart = 8*currentWebRequestPageIndex + 1;

      var serviceWebSearch:HTTPService = new HTTPService();

      serviceWebSearch.url = 'http://ajax.googleapis.com/ajax/services/search/web';

      serviceWebSearch.request.v = '1.0';

      serviceWebSearch.request.q = SearchInput.text;

      //serviceWebSearch.request.start=currentWebResultStart;

      serviceWebSearch.request.rsz='large'

      serviceWebSearch.resultFormat = 'text';

      serviceWebSearch.addEventListener(ResultEvent.RESULT, onWebSearchResponse);

      serviceWebSearch.send();

      }

       

      private function onWebSearchResponse(event:ResultEvent):void {

      try {

      var json:Object = JSON.decode(event.result as String);

      var results:Array = json.responseData.results;

      webSearchResults = new ArrayCollection(results);

      webResponseRecieved = true;   

      var webResposePage:int = int(json.responseData.cursor.currentPageIndex);

      //previousEnabled = webResposePage>0;

       

      //webSearchStatus = "Displaying "+((currentWebRequestPageIndex*8)+1)+" - "+((currentWebRequestPageIndex*8)

      //+ json.responseData.cursor.pages.length)

      //+" of "+json.responseData.cursor.estimatedResultCount;   

       

      } catch(ignored:Error) {

      }

      }

       

      it return just links, not the actual product information like you will find in www.google.com/products search.

        • 1. Re: Performing Google Product search in Flex 4.5
          Chaos7703

          Does the response contain the product information?  If you're able to parse & use links from the result, then it sounds like the JSON is being read correctly, but you may not be getting what you expect / want back from Google.  I would recommend throwing placing a textarea on the screen and dumping the event.result.toString() just to ensure that the product information you want is actually there to be parsed.

           

          If it's not then, you need to verify your request parameters and Google's documentation.  They may have changed the name of the dataset, their terms of service, or something like that.

           

          If the information is in the returned result, then an example of an actual returned response might be helpful.