Posted in ColdFusion | Posted on 09-24-2009 | 3,386 views
Just a quick note that I spent some time at lunch looking at my CFYahoo package. Now that Yahoo has put the ColdFusion Dev Center back up, I knew that I'd need to look at my CFCs. I created a backup of the current CFC package and took a look specifically at search support. It had changed quite a bit so I rewrote the CFC. Luckily Yahoo's APIs are still stupid-easy to use so this wasn't a big deal. I've decided to go ahead and update the release with new code for: Search and Weather. The other services will be upgraded over time. The package now requires ColdFusion 8. Just in case folks are curious - this is how easy it is to use the API:
2
3<cfinvoke component="#searchAPI#" method="search" returnVariable="result">
4 <cfinvokeargument name="query" value="coldfusion blog">
5</cfinvoke>
6
7<cfdump var="#result#" label="Search for 'coldfusion blog'">
The result is a nice query you can use like any other ColdFusion query.
And here is a weather example:
2<cfinvoke component="#weatherAPI#" method="getForecast" returnVariable="result">
3 <cfinvokeargument name="location" value="70508">
4 <cfinvokeargument name="units" value="F">
5</cfinvoke>
6
7<cfdump var="#result#" label="Forecast for Lafayette, LA">
And the result:



Where 70508 magic number was taken from ? Is there interface for location lookup ? Thanks !
<cfset day.code = xmlResult.rss.channel.item["yweather:forecast"][x].xmlAttributes.code>
So I know which weather graphic to pull.