Hi,
Many people write there blogs such as Sharepoint Blog, ASP.Net Blog, and others. Sometimes it is difficult to remember those blog names. So google provides the API for this.
It will provide Owner Name, Link to profile and list of all the blogs that owner has.
If you wants to try this yourself use the following Script.
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("gdata", "1.x", { packages : ["blogger"] });
</script>
<script type="text/javascript">
function _run()
{
/* Retrieve a list of blogs */
// Obtain a reference to the 'content' div
var content = document.getElementById('content');
// Create the blogger service object
var bloggerService = new google.gdata.blogger.BloggerService('com.appspot.interactivesampler');
// The default "metafeed" feed is used to retrieve a list of blogs for a particular logged-in user.
// The ID included in this URI can be retrieved from the <link rel="me"> element in the Blog's HTML source
// Hightlighted ID has to be changed as per the blog.
var feedUri = 'http://www.blogger.com/feeds/16112369086732751558/blogs';
// The callback method invoked when getBlogFeed() returns feed data
var handleBlogFeed = function(blogFeedRoot) {
// Display Blogger Profile data
var author = blogFeedRoot.feed.getAuthors();
var authorName = author[0].getName().getValue();
var authorUri = author[0].getUri().getValue();
// This variable will buffer HTML output until execution is complete
var html = '<h1>Blogger User</h1>'
+ '<h2>Profile Information</h2>'
+ '<dl>'
+ '<dt>Profile Name:</dt>'
+ '<dd>' + authorName + '</dd>'
+ '<dt>Profile Name:</dt>'
+ '<dd><a href="' + authorUri + '">' + authorUri + '</a></dd>';
// Fetch blogs associated with this Blogger Profile
html += '<h2>Blog List</h2>';
var blogEntries = blogFeedRoot.feed.getEntries();
// Has the user created any blogs?
if(!blogEntries.length)
{
html += '<p>First <a href="http://www.blogger.com" '
+ 'target="_blank">create a blog</a>.</p>';
}
else
{
// Print list of blogs
html += '<table rules="groups">'
+ '<thead><tr>'
+ '<th>Blog Name/Link</th><th>Last Updated</th>'
+ '</tr></thead>'
+ '<tbody>';
for (var i = 0, blogEntry; blogEntry = blogEntries[i]; i++)
{
var blogTitle = blogEntry.getTitle().getText();
var blogURL = blogEntry.getHtmlLink().getHref();
var blogUpdated = blogEntry.getUpdated().getValue().getDate();
html += '<tr>'
+ '<td><a href="' + blogURL + '" target="_blank">'
+ blogTitle
+ '</a></td>'
+ '<td>' + blogUpdated + '</td>'
+ '</tr>';
}
html += '</tbody>'
+ '</table>';
};
// Output buffered HTML and clear 'Loading...' messagecontent.innerHTML = html;
};
// Error handler called when getBlogFeed() produces an error
var handleError = function(error)
{
content.innerHTML = '<pre>' + error + '</pre>';
};
// Submit the request using the blogger service object
bloggerService.getBlogFeed(feedUri, handleBlogFeed, handleError);
}
google.setOnLoadCallback(_run);
</script>
<body style="font-family: Arial;border: 0 none;">
<div id="content" style="width:100%;">Loading...</div>
</body>
No comments:
Post a Comment