How-To Parse RSS Feeds With Google’s Feed API

How-To Parse RSS Feeds With Google’s Feed API

Tired of processing RSS/Atom feeds in your app? Today Google announced their new Google AJAX Feed API that will do the parsing (and caching!) for you. It works great for Javascript developers, but what if you want to use a server side language like PHP? Here’s a quick (and totally unauthorized) hint to let you do so.

Digging through Google’s Javascript code, we find that they make a request to the Google mothership to parse a feed using this url:

In theory, just insert a link to the feed you want parsed into their url and voila! Sort of.

The feed data is returned inside a Javascript object. Before we can use it we need to extract the real data and convert JSON’s escaped unicode characters into their HTML equivalents.


    $url = urlencode("");

    $data = file_get_contents("

    preg_match('/{(.*?)}/', $data, $matches);

    $data = json_decode($matches[0])->xmlString;


And with that, we’re done! You can throw any type of feed at Google’s parser and you’ll get back the data as a well-formed Atom feed. Throw in a little SimpleXML and you’re all set.

Jon Henshaw
Co-Founder and President

Jon is the Co-founder and President of Raven Internet Marketing Tools.

Jon is the Co-founder and President of Raven Internet Marketing Tools.

  • Kjell

    when i learned about that api i was thinkin exactly the same. :) was only too lazy to dig up the goods, heh.

    thank you!

  • athi

    I tried changing the file_get_contents to CuRl
    It returned GwebSearch.RawCompletion(‘0′,null, 400, ‘invalid version’, 200)
    Do You Know Why? thanks but file_get_contents work.


  • Otto

    More modern way:

    The q= is the escaped URL of the feed. The result is json data.

    PHP Code to do it:
    $url = urlencode(“”);

    $data = file_get_contents(“$url”);

    $data = json_decode($matches[0])->xmlString;

    Easy. You can also find out feed addresses for websites and do searches this way:

  • Otto

    Whoops, make that last line this:
    $data = json_decode($data)->xmlString;

  • Richard.Williams

    We use biterscripting ( ) for parsing RSS. It’s very flexible.