Skip to Content
Yahoo! Hacks
book

Yahoo! Hacks

by Paul Bausch
October 2005
Intermediate to advanced
489 pages
12h 2m
English
O'Reilly Media, Inc.
Content preview from Yahoo! Hacks

Program Yahoo! with ColdFusion

ColdFusion MX includes all of the tools necessary to work with the Yahoo! API.

ColdFusion is a development platform for creating web applications. Its tag based template structure is a popular choice for HTML developers who want to move to more dynamic content and are already familiar with using tags. In fact, if you were to glance at a ColdFusion script, you might think the code was standard HTML. Putting together a ColdFusion template is a lot like putting together an HTML page, but you can draw on resources such as databases and web services to bring in dynamic content.

You’ll need to be running a version of ColdFusion MX or later to use this hack, because it relies on the XmlParse function that was added with the MX release. This function can take an XML document, such as the responses from Yahoo! Search Web Services, and turn it into an object that Cold-Fusion scripts can work with.

The Code

This hack shows how you can quickly use the ColdFusion Markup Language (CFML) to bring in content from Yahoo! Search Web Services. This script assembles the proper request URL based on a querystring variable and gets a response from Yahoo! with the <cfhttp> tag. Then the XmlParse function makes the data available to the script, and the <cfloop> tag goes through each bit of data, adding it to the page.

Save the following code to a file called yahoo_search.cfm and upload it to your server:

<!--- yahoo_search.cfm Accepts a search term and shows the top results. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
How to Become a Game-Changing Leader

How to Become a Game-Changing Leader

Douglas A. Ready, Alan Mulally
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer

Publisher Resources

ISBN: 0596009453Supplemental ContentErrata Page