KRL and Yahoo Local Search

Posted by Randall Bohn on Stack Overflow See other posts from Stack Overflow or by Randall Bohn
Published on 2010-12-26T04:51:23Z Indexed on 2010/12/26 4:54 UTC
Read the original article Hit count: 281

Filed under:
|

I'm trying to use Yahoo Local Search in a Kynetx Application.

ruleset avogadro {
  meta {
    name "yahoo-local-ruleset"
    description "use results from Yahoo local search"
    author "randall bohn"
    key yahoo_local "get-your-own-key"
  }
  dispatch { domain "example.com"}
  global {
    datasource local:XML <- "http://local.yahooapis.com/LocalSearchService/V3/localsearch";
  }

  rule add_list {
    select when pageview ".*" setting ()
    pre {
      ds = datasource:local("?appid=#{keys:yahoo_local()}&query=pizza&zip=#{zip}&results=5");
      rs = ds.pick("$..Result");
    }
    append("body","<ul id='my_list'></ul>");
    always {
      set ent:pizza rs;
    }
  }

  rule add_results {
    select when pageview ".*" setting ()
    foreach ent:pizza setting pizza
    pre {
      title = pizza.pick("$..Title");
    }
    append("#my_list", "<li>#{title}</li>");
  }
}

The list I wind up with is

. [object Object]

and 'title' has

{'$t' => 'Pizza Shop 1'}

I can't figure out how to get just the title.

© Stack Overflow or respective owner

Related posts about krl

Related posts about pick