Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

create a hyperlink with google API feed

Posted on 2013-05-23
1
Medium Priority
?
1,017 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
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:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

876 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