Advertisement
darkufo

Blogger Feed Example

Nov 19th, 2012
98
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  5. <title>Blogger Data API Sample</title>
  6. <script src="http://www.google.com/jsapi" type="text/javascript"></script>
  7. <script type="text/javascript">
  8. google.load("gdata", "1.x", { packages : ["blogger"] });
  9. </script>
  10. <script type="text/javascript">
  11. function _run() {
  12. /*
  13. * Retrieve a list of blog posts
  14. */
  15.  
  16. // Obtain a reference to the 'content' div
  17. var content = document.getElementById('content');
  18.  
  19. // Create the blogger service object
  20. var bloggerService =
  21. new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
  22.  
  23. // The feed for a single blog. (In this case, the Official Google Blog.)
  24. //
  25. // The ID included in this URI can be retrieved from the
  26. // <link rel="service.post"> element in the Blog's HTML source
  27. var feedUri = 'http://www.spoilertv.com/feeds/posts/default?published-min=2012-11-18T14:00:00&published-max=2012-11-19T23:59:00&max-results=500';
  28.  
  29. // A callback method invoked getBlogPostFeed() returns data
  30. var handleBlogPostFeed = function(postsFeedRoot) {
  31. var posts = postsFeedRoot.feed.getEntries();
  32.  
  33. // This variable will buffer HTML output until function completes
  34. var html = '';
  35.  
  36. // Display blog's title
  37. html += '<dl>'
  38. + '<dt>'
  39. + '</dt>';
  40.  
  41. // Display blog posts
  42. html += '<dd>';
  43. for (var i = 0, post; post = posts[i]; i++) {
  44. var postTitle = post.getTitle().getText();
  45. var postURL = post.getHtmlLink().getHref();
  46. html += '&lt;a href="' + postURL + '" target="_blank">'
  47. + postTitle
  48. + '&lt;/a&gt<br/>';
  49. }
  50. html += '</dd>';
  51.  
  52. // Write out buffered HTML, and clear the "Loading..." message
  53. content.innerHTML = html;
  54. };
  55.  
  56. var handleError = function(error) {
  57. content.innerHTML = '<pre>' + error + '</pre>';
  58. };
  59.  
  60. bloggerService.getBlogPostFeed(feedUri, handleBlogPostFeed, handleError);
  61.  
  62. }
  63. google.setOnLoadCallback(_run);
  64. </script>
  65. </head>
  66. <body style="font-family: Arial;border: 0 none;">
  67. <div id="content" style="width:100%;">Loading...</div>
  68. </body>
  69. </html>
Advertisement
RAW Paste Data Copied
Advertisement