2008年12月20日星期六

Using .NET Google API Library to grab info from this blogger

New application possibilities always lie within open infrastructures, with google api library, developers and hackers can do lots of things they like. Well, just remember, imagination is much more important than technics, technics are only building tools.

Happy to find out .NET SDK for Google API is available for downloading, so I have had a try on it. The documents for the library are not as good as MSDN, but enough for me to work out a working code snippet in a short while.

// The following C# code is by Joshua

// Initializes a Service instance
// The 1st parameter should be "blogger" for we're requesting blogger service data
// The 2nd parameter, write as you wish
Service service = new Service("blogger", "TestApp");

// Send your Google account to the server
service.setUserCredentials(userName, password);

// Initializes a feed query object
FeedQuery query = new FeedQuery();

// Any valid uri of a blogger's feed is OK
query.Uri = new Uri(@"http://newutopianblue.blogspot.com/feeds/posts/default");

// Format output
AtomFeed feed = null;
try
{
feed = service.Query(query);

Console.WriteLine("This feed is generated by " + feed.Generator.Text);
Console.WriteLine(feed.Title.Text);
Console.WriteLine("Author: "+feed.Authors[0].Email+"\n");
foreach (var entry in feed.Entries)
{
Console.WriteLine("Blog title: " + entry.Title.Text);
Console.WriteLine("Link: " + entry.AlternateUri.Content+"\n");
}
}
catch (Exception ex) { Console.WriteLine(ex.Message); }

Console.ReadLine();


The output result :

This feed is generated by Blogger
Utopian Blue
Author: Garfilone@gmail.com

Blog title: Introduction to My Virtual Microscopy Solution
Link:
http://newutopianblue.blogspot.com/2008/12/introduction-to-my-virtual-micr
oscopy.html

Blog title: Works Collection II
Link: http://newutopianblue.blogspot.com/2008/12/works-collection-ii.html

Blog title: Something on gOS
Link: http://newutopianblue.blogspot.com/2008/12/gos-cloud-presentation.html

Blog title: Live Mesh Beta 试用
Link: http://newutopianblue.blogspot.com/2008/12/live-mesh-beta.html

Blog title: [Ad]首届研究生英语口语风采大赛
Link: http://newutopianblue.blogspot.com/2008/12/ad.html

Blog title: 一个制作卡通头像的网站
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_29.html

Blog title: Twitter&Twhirl体验 & 观点随笔
Link: http://newutopianblue.blogspot.com/2008/11/twitter.html

Blog title: 谁说大象不能跳舞 读书摘记(三)
Link: http://newutopianblue.blogspot.com/2008/11/1-ibm-2-dna-3-4-5-6-1.html

Blog title: Works Collection I
Link: http://newutopianblue.blogspot.com/2008/11/everything-happens-to-me.html

Blog title: The Road
Link: http://newutopianblue.blogspot.com/2008/11/road.html

Blog title: 堇若 【十】
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_23.html

Blog title: 接触Azure Services Platform
Link: http://newutopianblue.blogspot.com/2008/11/azure-services-platform.html

Blog title: 我为什么选择Google的产品
Link: http://newutopianblue.blogspot.com/2008/11/google.html

Blog title: 谁说大象不能跳舞 读书摘记(二)
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_19.html

Blog title: 春秋 Live@VOX 2008.11.15
Link: http://newutopianblue.blogspot.com/2008/11/livevox-20081115.html

Blog title: 谁说大象不能跳舞 读书摘记(一)
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_14.html

Blog title: 好好享受毕业前的校园时光
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_13.html

Blog title: [Ad]华中科技大学RoboCode Java机器人AI设计大赛
Link: http://newutopianblue.blogspot.com/2008/11/adrobocode-javaai.html

Blog title: 堇若 【九】
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_10.html

Blog title: 关于《挪威的森林》的阅读记忆
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_09.html

Blog title: 为白云PieFriends版活动制作的3张进站图
Link: http://newutopianblue.blogspot.com/2008/11/piefriends3.html

Blog title: 扯淡一下白云黄鹤BBS
Link: http://newutopianblue.blogspot.com/2008/11/bbs.html

Blog title: Google Analytics给我的第一份数据报告
Link: http://newutopianblue.blogspot.com/2008/11/google-analytics.html

Blog title: 原作者
Link: http://newutopianblue.blogspot.com/2008/11/blog-post_06.html

Blog title: 弃用MSN Spaces
Link: http://newutopianblue.blogspot.com/2008/11/msn-spaces.html

没有评论:

发表评论