Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
107 lines (82 sloc) 2.91 KB

feedle

Feedle is a jQuery plugin for the Google Feeds API. It offers two methods to access the API, namely load, to load the entries from a given URL, and find, to find feeds based on queries.

It goes without saying that jQuery is a dependency. The primary use of jQuery is for the $.getJSON method, otherwise the same can be replicated pretty easily in plain javascript.

Google also offers a pure javascript API that you can check out at Google Feed Javascript API, although that seems just a tad more complicated in comparison.

Usage

Feedle has two methods load and find.

Basic Usage

To get started, download the feedle.jquery.js or feedle.jquery.min.js file from the build directory and add it to your page, along with jQuery.

<html>
    <head>
        ...
    </head>
    <body>
        ...
        <!-- You do add your javascript at the bottom, don't you? :-) -->
        <script src="jquery.js"></script>
        <script src="feedle.jquery.js"></script>
    </body>
</html>

After that, you can directly call either load or find. For example -

  1. load
$.feedle.load({
    url: "http://feeds.feedburner.com/fastcodesign/feed",
    success: function(feed) {
        // Add your custom logic here
    }
});
  1. find
$.feedle.load({
    query: "Google",
    success: function(query, entries) {
        // Add your custom logic here
    }
});

Reference

You can see all the options that the methods take over here. 1. load

$.feedle.load({
      url: "Your url", // REQUIRED parameter. No need to encode the url.

    // REQUIRED: Specify a callback function, else the load will call a default do-nothing function.
    success: function(feed) {
        // Your code here.
    }, 

    // OPTIONAL: Feedle can pass the whole response to the success function if this parameter is specified.
    rawResponse: false,

    // OPTIONAL: If you want to get notified in case the API gives an error.
    error: function(code, message) {
        // Your code here.
    }, 

    // OPTIONAL: If you want a host language other than english
    hostLanguage: 'en',

    // OPTIONAL: The API default is 4. For max entries, specify -1
    numEntries: 4, 

    // OPTIONAL: If true, historical items of the feed, which Google has cached, will be available.
    historicalItems: true | false
});
  1. 'find'
$.feedle.find({
    query: "Your query", // REQUIRED parameter.

    // REQUIRED: Specify a callback function, else the load will call a default do-nothing function.
    success: function(feed) {
        // Your code here.
    }, 

    // OPTIONAL: If you want to get notified in case the API gives an error.
    error: function(code, message) {
        // Your code here.
    }, 

    // OPTIONAL: If you want a host language other than english
    hostLanguage: 'en',
});

Credits

Varghese Matthew gave the idea to build such a plugin.