# File ads/smaato.rb, line 30
      def getAd(keywords)
        logger.info "Smaato ad retrieval"
??
        @@userId=request.env['HTTP_USERID'] 
        if (@@userId.nil?)
          @@userId="101"
        end
        # build up the various arguments in the adArgs hash
        adArgs= SequencedHash.new
        adArgs["pub"]="3517" # replace with real publisher ID
        adArgs["adspace"]="137" # what is the ad space and published ID taht we need
        adArgs["format"]="JPG"
        adArgs["numads"]="1"
        adArgs["offline"]="true"
        adArgs["width"]="176"  # get these from device capabilities service instead!
        adArgs["height"]="208"  # get these from device capabilities service instead
        adArgs["response"]="XML"
        adArgs["user"]=@@userId # user agent for our browser.  
        if (keywords)
          adArgs["kws"]=CGI::escape(keywords) 
        end
        # now built the URL to call out to based upon the base URL and ad hash
        adURL=@@adServer + "?"
        first=1 # dont put ampersand on first one
        adArgs.each_key do |x|
          if adArgs[x]
            (adURL=adURL+"&") unless first
            first=nil # start putting in &s
            adURL = adURL + x + "=" + adArgs[x]   
          end
        end
??
        # ok, now call google's mobile adSense service and get back the full ad 
        @adxml=open(adURL).read
??
        if (@adxml)
          adDoc = REXML::Document.new @adxml
          @adelement = adDoc.elements["//ad"]
          if (@adelement)
            @adurl=@adelement.elements["link"].text
            @urltext=@adelement.elements["adtext"].text
            @urltext||="LINK TO AD" 
          end
        end
      end