TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 728
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 470
  • Total: 471
  • @rjen

external RSS as ARTICLE using google api

Started by chulian1819@gmail.com, July 30, 2008, 07:29:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

chulian1819@gmail.com

In my hosting  i have a restriction to use fopen of an outside file, and the rss block dosent work so i used this one:


http://www.javascriptkit.com/dhtmltutors/googleajaxfeed.shtml

follow this simple steps:
Quote
Step 1: Get your own (free) Google API key instantly, by going to their  signup page, and entering your site's domain. A key that is super-duper-long is generated that will work only for that domain.

Step 2: Insert the following script in the HEAD section of your page, which first references Google Code API (required), then loads version 1 (currently the latest version) of Ajax Feed API:

<head>
<script type="text/javascript" src="http://www.google.com/jsapi?key=YOUR-API-KEY">
</script>

<script type="text/javascript">
google.load("feeds", "1") //Load Google Ajax Feed API (version 1)
</script>
</head>

Step 3: Now that you have access to Google Ajax Feed API on your page, all that's left is to use JavaScript to load the desired RSS feed, then retrieve and display the results in the desired manner. For example:

<div id="feeddiv"></div>

<script type="text/javascript">

var feedcontainer=document.getElementById("feeddiv")
var feedurl="http://rss.slashdot.org/Slashdot/slashdot"
var feedlimit=5
var rssoutput="Latest Slashdot News:
<ul>"

function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl) //Google Feed API method
feedpointer.setNumEntries(feedlimit) //Google Feed API method
feedpointer.load(displayfeed) //Google Feed API method
}

function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries
for (var i=0; i<thefeeds.length; i++)
rssoutput+="<li><a href='" + thefeeds.link + "'>" + thefeeds.title + "</a></li>"
rssoutput+="</ul>"
feedcontainer.innerHTML=rssoutput
}
else
alert("Error fetching feeds!")
}

window.onload=function(){
rssfeedsetup()
}

</script>



now i made this tiny article:

    <script type="text/javascript" src="http://www.google.com/jsapi?key=AQQ"></script>
    <script type="text/javascript">
    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed("http://news.google.com/news?hl=es&tab=bn&q=politics&ie=UTF-8&output=rss");
      feed.setNumEntries(4);
      feed.load(function(result) {
        if (!result.error) {
          var container = document.getElementById("feed");
          for (var i = 0; i < result.feed.entries.length; i++) {
            var entry = result.feed.entries[i];
            var div = document.createElement("div");
            div.appendChild(document.createTextNode(entry.title));
            //div.innerHTML="<a href='"+entry.link+"' >wasa</a>"+entry.content;
            div.innerHTML=entry.content;           
            container.appendChild(div);
          }
        }
      });
    }
    google.setOnLoadCallback(initialize);

    </script> 
   

  <MARQUEE    behavior="scroll" direction="up" height="150px"  SCROLLAMOUNT="2" onmouseover="this.stop()" onmouseout="this.start()"  >
    <div id="feed" style="height:600px; "></div>
   </MARQUEE> 


that look´s good!

You can add more than 1 feed, just add to the function initialize a new google.feeds.Feed
hope u like it

bb

tanks to http://www.javascriptkit.com

G6Cad

Think that can be very usefull for some mebers  :)
Thanks for sharing it with us  :up:

This website is proudly hosted on Crocweb Cloud Website Hosting.