Click here to Skip to main content
15,561,681 members
Articles / Web Development / ASP.NET
Posted 16 Jul 2012


13 bookmarked

Blog integration into ASP.NET website using GData API

Rate me:
Please Sign up or sign in to vote.
5.00/5 (6 votes)
16 Jul 2012CPOL3 min read
Content Managemnt of website using Blogger Blog and Google GDI API


Many websites for individuals and companies consist of mostly static pages but sometimes there is a need to provide updates to customers or information about the company news. Most of these websites would require actual update of the code to publish these news items or updates. For smaller companies a dynamic way to maintain these pages can be integration into blog site where by the contents of the blog is automatically pulled into the page which is to be updated. This provides a way to manage content on these pages without touching the code on the website or doing a deployment. An update to the blog is reflected directly into the target page. This article provides one such implementation of this feature using the blogger website and ASP.NET website. Elsewhere on this site blog integration into ASP.NET blogger is discussed with FTP solution, but this feature is being phased out. My solution involves using the GData service API from Google to query the blog connects on the fly and display them in your ASP.NET website, although there is no reason why it cannot be used in other other types of websites.


The Incede.BloggerInteg.dll is written in C#3.5 and the sample webpage is designed in VS2008. It should be easily upgradable to VS2010.

Using the code

The project is implemented as a custom DLL (Incede.BloggerInteg.dll), This component has BlogService class with a public method GetUserBlogs() which returns a list the blogs published on the specified blogger site.

The constructor of the BlogService service class takes the blog name, user id, password of the blog as arguments. Also included in the constructor is the number of blog entries to pull. At the core of the component are two API's from Google for access to the blogger system.

  • Google.GData.Blogger
  • Google.GData.Client

These components provide the necessary service of online authentication into the blogger platform and ability to query the user blogs. The GetUserBlogs first creates an instance of the service credentials using the Google GDataCredentials and the service is getting the blog entries using the GDATA and the Blog URI.

public List<blogentry> GetUserBlogs()
    if (blogname.Trim().Equals(String.Empty))
        blogname = "";//default if not supplied
    if (numberOfEntries <= 0)
        numberOfEntries = 10; //default

    var gService = new Google.GData.Client.Service("blogger", blogname);
    gService.Credentials = new GDataCredentials(username, password);

    Uri blogPostUri = SelectUserBlog(gService, blogname)
    List<blogentry> blogs = GetBlogEntryContent(gService, 
    blogPostUri,   numberOfEntries);
    return blogs;

This is the method where the core of the process of identifying the user blogs is performed. An atomfeed is first created from the query and then the entries are filtered down to the user blog. This user blog is identified by a static URI.

static Uri SelectUserBlog(Service service, string blogname)
    //blogname = example 
    FeedQuery query = new FeedQuery();
    // Retrieving a list of blogs
    query.Uri = new Uri("");
    AtomFeed feed = service.Query(query);

    // Publishing a blog post
    Uri blogPostUri = null;
    if (feed != null)
        foreach (AtomEntry entry in feed.Entries)
            //iterate thru blogs 

            if (entry.AlternateUri.Content.Contains(blogname))
                // find the href in the link with a rel pointing to the blog's feed
                for (int i = 0; i < entry.Links.Count; i++)
                    if (entry.Links[i].Rel.Equals(""))
                        blogPostUri = new Uri(entry.Links[i].HRef.ToString());

                return blogPostUri;
    return blogPostUri;

This method finally iterates through the entries of the user blog URI identified and pulls the relevant content from the blog such as the title, content, and footer.

static List<blogentry> GetBlogEntryContent(Service service, Uri blogUri, int numberOfEntries)
    List<blogentry> allblogs = new List<blogentry>();
    if (blogUri != null)

        // Retrieve all posts in a blog
        FeedQuery query = new FeedQuery();
        query.Uri = blogUri;
        query.NumberToRetrieve = numberOfEntries; //get last x number of posts
        AtomFeed feed = service.Query(query);
        foreach (AtomEntry entry in feed.Entries)
            BlogEntry b = new BlogEntry();
            b.Title = entry.Title.Text;
            b.content = entry.Content.Content;
            b.footer = String.Format("Posted on {0}", entry.Published.ToString());
    return allblogs;


To use the component we simply create an instance of the service Incede.BloggerInteg.BlogService and supply it with a few parameters ie the blogname, credentials, and the number of blog entries we are interested in pulling. These parameters are defined in the web.config in our sample project. The service returns a IList of blog entry class with properties such as Blog title, Blog Content and footer.ShowBlogEntries simply formats the blog entries into a data list for display.

Incede.BloggerInteg.BlogService Biservicc = new Incede.BloggerInteg.BlogService(blogname, userid,pwd,int.Parse(entries));
List<incede.bloggerinteg.blogentry> blogs =   Biservicc.GetUserBlogs();
ShowBlogEntries(blogs, blogname);

Putting it together

  1. The bin directory should contain the following supporting DLLs:
    • Google.GData.Blogger.dll
    • Google.GData.Client.dll
  2. You web.config should have following entries for the URL to the blogsite and the credentials:
    • blogName
    • blogUserid
    • blogPass
    • noOfEntries
  3. You can modify the core service to return additional parameters from the blogger site if needed. My implementation has the most  basic items that would be needed. 

Sample Project 

I have used a sample blog I created for this project to illustrate the concept in the sample project. The actual blog site is Any updates to the blog are automatically pulled down into the sample project webpage. A live implementation of this in action can be seem on my website

Screen Shot of the integrated page: 

Image 1 


  • Initial post 7/15/2012.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
United States United States
Lead Enterprise Application development and architecture using with back end databases like Ms-SQL, Oracle.

You can contact me at

Comments and Discussions

QuestionIs the method of authentication still work? Pin
Lyubomir Rumenov Velchev9-Nov-15 13:44
Lyubomir Rumenov Velchev9-Nov-15 13:44 
Hi I tried to use your example. Tried it with mine username and password for blogger, but I got not authorised exception. Do you know if that method of authorisation is still valid?
QuestionWhere is GData Pin
krishnananda4222-Nov-14 9:55
krishnananda4222-Nov-14 9:55 
QuestionComprehensive and Smart but complete article on an instance. Pin
ijazuddin jafri18-Nov-12 17:06
ijazuddin jafri18-Nov-12 17:06 
QuestionWhere is GData.Blogger dll Pin
Ravinder Singh Bhawer17-Oct-12 22:40
Ravinder Singh Bhawer17-Oct-12 22:40 
GeneralMy vote of 5 Pin
anaparthiarun25-Jul-12 4:41
anaparthiarun25-Jul-12 4:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.