stephenjbell

Basic Yahoo BOSS Search (using JSON) in dotCMS

May 3rd, 2011
498
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. ## !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  2. ## IMPORTANT: This code will cease functioning in July 2011 when Yahoo BOSS discontinues the first version of their API and moves everyone to a new paid version
  3. ## You would be much better off using Bing API search that I made after this: http://pastebin.com/D6ABsdsa
  4. ## !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  5.  
  6.  
  7. ####### Basic Yahoo BOSS (http://developer.yahoo.com/search/boss) search in dotCMS
  8. ####### Modified May 4, 2011 to get rid of a bunch of unnecessary .get() statements
  9.  
  10.  
  11. ## Your Yahoo Application ID (Info here: http://developer.yahoo.com/faq/)
  12. #set($appId="YOURAPPID")
  13.  
  14. ## Gets your search term from the query string on your site (e.g. www.mysite.com/search.dot?q=odie)
  15. #set($mySearch=$request.getParameter("q"))
  16.  
  17. ## Determine which sites you would like to search
  18. #set($sites="www.garfield.com,www.gocomics.com")
  19.  
  20. ## Puts it all together
  21. #set($jsonPath = "http://boss.yahooapis.com/ysearch/web/v1/$!{mySearch}?appid=$!{appId}--&format=json&sites=$!{sites}")
  22.  
  23.  
  24. #set($myjson = $json.fetch("$jsonPath"))
  25. #set($resultset=$myjson.ysearchresponse.resultset_web)
  26.  
  27. <h1>Searching for term "$mySearch"</h1>
  28.  
  29. <ul>
  30. #foreach($result in $resultset)
  31. <li>
  32. <h2>$result.title</h2>
  33. <p>$result.abstract</p>
  34. <a href="$result.clickurl">$result.dispurl</a>
  35. </li>
  36. #end
  37. </ul>
Add Comment
Please, Sign In to add comment