Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12

Thread: RSS feeds using YQL stopped working

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Well just as a point of information, the gfeedfetcher update (like the script it's based on) has more built in flexibility, can handle dates and times without your needing to code for that, anticipates future possible glitches, is more modular, but requires slightly more upfront code loading. So, if you're using it a lot (on two or more pages or for several instances on a page), and/or want the flexibility of easily combining feeds, and/or including ATOM feeds, it's the obvious choice. It does require some usage learning, if you're not already familiar with the gfeedfetcher approach.

    Then again, if you just want one page and three feeds or less, and want to tailor the callback function(s) (output) in very specific ways, perhaps you would want to go with the JavaScriptKit modification, which can be further modified by you (with or without my help) to deal with specific output requirements and/or any other glitches which may or may not arise. Note that the JavaScriptKit modification could be made modular, so that only one main function would be required for two or more feeds on a page, as long as the output format were the same or similar for all of the feeds. It would be difficult to make it handle ATOM feeds.

    Further, both mods have the advantage over their respective predecessors of being able to run on an SSL (htpps/secure) page, which neither of the previous code versions for either script could do.
    Last edited by jscheuer1; 09-04-2017 at 01:57 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #12
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,373
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Oh, and here's a modular version of the updated JavaScriptKit method:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Simple YQL Modular Version</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    </head>
    <body>
     
    <div id="qznews"></div>
    <div id="nbcnews"></div>
     
    <script>
    function parsefeed(cfig, c){
    	var numretries = 30; // increase this number (number of retries) if you're still having problems
    
    		//////// No Need To Edit Beyond Here Unless You Want To /////////
    
    	var counter = typeof c === 'number'? c : numretries;
    	var head = document.getElementsByTagName('head')[0];
    	var s = document.createElement('script');
    	window["callback_" + cfig.id + (--counter)] = function(r){
    		head.removeChild(s);
    		if(r && r.query && r.query.count === 0 && counter > 0){
    			return parsefeed(cfig, counter);
    		}
    		window.console && console.log(cfig.id + ': ' + counter); // for optional diagnostic info - may be removed or commented out
    		//r now contains the result of the YQL Query as a JSON
    		var feedmarkup = '<p>', i = -1;
    		var feed = r.query.results.item // get feed as array of entries
    		while (++i < feed.length){
    			feedmarkup += '<a href="' + feed[i].link + '">';
    			feedmarkup += feed[i].title + '</a><br />';
    			feedmarkup += feed[i].description + '</p>';
    		}
    		document.getElementById(cfig.id).innerHTML = feedmarkup;
    	};
    	var baseurl = "https://query.yahooapis.com/v1/public/yql?q=";
    	s.src = baseurl + encodeURIComponent(cfig.query) + "&format=json&callback=callback_" + cfig.id + counter;
    	head.append(s);
    }
    parsefeed({id: 'qznews', query: 'select * from rss(0,5) where url = "http://qz.com/feed/"'});
    parsefeed({id: 'nbcnews', query: 'select * from rss(0,5) where url = "http://feeds.nbcnews.com/feeds/topstories"'});
    </script>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. FaseSlideShow Script not working stopped working on Sunday?
    By JARDesign in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 03-18-2014, 01:25 PM
  2. Lytebox stopped working for me
    By SundayBuffalo in forum JavaScript
    Replies: 1
    Last Post: 10-05-2009, 03:28 PM
  3. Mind stopped working
    By vaibhav24in in forum JavaScript
    Replies: 2
    Last Post: 02-12-2007, 11:05 AM
  4. My script stopped working, please help
    By martin_thomasr in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-05-2006, 12:23 PM
  5. Pop-up Window Stopped Working
    By NoClue in forum JavaScript
    Replies: 5
    Last Post: 11-17-2004, 11:16 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •