Solved

create a hyperlink with google API feed

Posted on 2013-05-23
1
841 Views
Last Modified: 2013-11-18
Hello,
I am using the google FEED API
https://developers.google.com/feed/v1/devguide

I got the basic going very easy, the results are plain text though. I want to results to be hyperlinks back to blog posts

For JSON, XML, Mixed it tells you to use LINK, but it does not have a single sample on how to use it (are we supposed to instinctively know?)

Please help
0
Comment
Question by:jblayney
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39191753
Combining the 'hello world' example with a line of code found later on in the page (but using link instead of url) gives this:
<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

    google.load("feeds", "1");

    function initialize() {
      var feed = new google.feeds.Feed("http://fastpshb.appspot.com/feed/1/fastpshb");
      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 = '<p><a href="' + entry.link + '">' + entry.title + '</a></p>';
            container.appendChild(div);
          }
        }
      });
    }
    google.setOnLoadCallback(initialize);

    </script>
  </head>
  <body>
    <div id="feed"></div>
  </body>
</html>

Open in new window

So the commented out line was replaced by the line below it which shows the article link.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn how to dynamically set the form action using jQuery.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question