Getting the latest headlines
Want to get the latest headlines? This recipe will let us use the "news" keyword to return the ten latest headlines.
Getting ready
The complete source code for this recipe can be found in the Chapter5/
folder.
How to do it...
This recipe will let us search
News:used
, for the latest headlines from Yahoo News. Create a file called news.php
in the pages
folder and add the following code to it:
<?php $results = news( ); $i = 1; $reply = array(); foreach($results->item as $item){ $msg = $item->title; $reply[] = $msg; } print_sms_reply( $reply ); function news( ){ $yelpql = 'select title from rss where url="http://rss.news.yahoo.com/rss/topstories" LIMIT 10'; $result = getResultFromYQL( $yelpql ); return $result->query->results; } ?>
How it works...
In step 1, we created our news.php
file in our pages folder, which lets us return the latest headlines. This API look up uses the Yahoo News RSS...