1

I'm working on an rss feed displayer for a webpage. I cant use PHP or Google API's. But can use Javascript, HTML and such. I created some code before but that used Google API's. I can't find a way how to use the code without Google API's. Here is the code that i used before:

<script type="text/javascript">
$(function(){
var feedUrl = 'www.feed.com' + 'feed'; //Example
    var postsToShow = 3;
$.ajax({
    type: 'GET',
    url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=' + postsToShow + '&callback=?&q=' + encodeURIComponent(feedUrl),
    dataType: 'json',
    success: function(xml){
        if(xml.responseData == null){
            alert('Unable to load feed, Incorrect path or invalid feed');
        }
        else
        {
            values = xml.responseData.feed.entries;
            console.log(values);
            for(var i = 0; i < postsToShow; i++){
                if(i >= values.length){
                    break;
                }
                var title = values[i].title;
                var content = values[i].contentSnippet;
                var link = values[i].link;
                if(title != null && content != null && link != null){
                    $('<a>',{
                        id: 'wpPostTitle' + i,
                        class: 'wpPostTitle',
                        title: title,
                        href: link,
                        text: title
                    }).appendTo('#wpFeed');
                    $('<p>',{
                        id: 'wpPostContent' + i,
                        class: 'wpPostContent',
                        title: title,
                        html: '<a href="' + link + '" id="wpPostContent' + i + '" class="wpPostContentLink">'+ content + '</a>'
                    }).appendTo('#wpFeed');
                }
            }
        }
    },
});
});
</script>
markieo
  • 484
  • 3
  • 14
  • What do you mean, not use google API? You are not using the Google API, this is a pure javascript implementation. The URL is for your RSS feed and you can change that to whichever RSS you want to access. – Husman Apr 25 '14 at 10:06
  • 1
    "url: document.location.protocol + '//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=' + postsToShow + '&callback=?&q=' + encodeURIComponent(feedUrl)" with this line of code i'm using Google Feed API. I cant use that. – markieo Apr 25 '14 at 10:07

0 Answers0