AnalogJ / zRSSFeed

zRSSFeed by Zazar, modified to support multiple RSS Feeds
11 stars 9 forks source link

Choice of provider? #3

Open julien51 opened 9 years ago

julien51 commented 9 years ago

You currently use Google's Feed API. Would you be open to a pull request which adds support to other APIs like @superfeedr's: see an example here.

bren1818 commented 7 years ago

Just to further comment - if you go here: https://developers.google.com/feed/ you'll see the Google API feed is deprecated as of: December 15th, 2016, meaning this will no longer work, you'll just get "This API is no longer available" returned. You could likely use https://rss2json.com as a replacement and add some simple json parsing to make it work the same...

AnalogJ commented 7 years ago

Hey guys, Yeah, I'm totally open to a PR to replace the google feed api with something else :)

bren1818 commented 7 years ago

Hi AnalogJ , I wrote a really quick way to essentially re-write your library.

Assuming you have a

with an attribute like "data-feed" which contained the rss feed, and had a class like "rssFeed"

The following script (using jQuery and the api.rss2json.com) would parse it and populate the div:

$('div.rssFeed').each(function(){
    var item =  $(this).attr('data-feed');
    var fullURL = 'https://api.rss2json.com/v1/api.json?rss_url=' + encodeURI( item );
    var p = $(this);
    $.get( fullURL, function( data ) {
        var html = "<ul>";
        for(var i =0; i < data.items.length; i++ ){
            //console.log( data.items[i].link );
            html = html + '<li><a target="_blank" href="' + data.items[i].link + '">' + data.items[i].title + '</a></li>';
        }
        $(p).html( html + '</ul>' );
    });
});

image

EX: <div class="rssFeed" data-feed="http://feed.dilbert.com/dilbert/daily_strip"></div>

Generates something like this:

image