Jump to content

Google Feed API Help

Ben Nash

Recommended Posts

I'm working with the Google Feed Api and made a search form to search for rss feeds.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
   <title>Google AJAX Search API Sample</title>
   <script src="//www.google.com/jsapi?key=AIzaSyAWetejqPLSq_LiLzg2jeJ98QWGiF8ocgQ" type="text/javascript"></script>
   <script type="text/javascript">
   *  How to find a feed based on a query.

   google.load("feeds", "1");

   function OnLoad() {
     // Query for president feeds on cnn.com
     var query = "<?= $searchfor ?>";
     google.feeds.findFeeds(query, findDone);

   function findDone(result) {
     // Make sure we didn't get an error.
     if (!result.error) {
       // Get content div
       var content = document.getElementById('content');
       var html = '';

       // Loop through the results and print out the title of the feed and link to
       // the url.
       for (var i = 0; i < result.entries.length; i++) {
         var entry = result.entries[i];
         html += '<p><a href="' + entry.url + '">' + entry.title + '</a></p>';
       content.innerHTML = html;

 <body style="font-family: Arial;border: 0 none;">

 <form action="play.php" method="POST" /> 
 Query: <input type="text" name="searchfor" />
 <input type="submit" name="search" />


if (isset($_POST['search'])) { 

$searchfor = $_POST['searchfor'];

if (empty($searchfor)) {
echo"No text entered.";
} else {

echo'<div id="content">Loading...</div>';





This is the code I have but when I search for something e.g. bbc news the text "Loading..." appears and it doesn't show any rss feeds. What is wrong???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...