The GooglePlus.NET library can be found here:
http://www.googleplustips.com/resources/3332-NET-Library-Google-APIs-released.aspx
Tony John, the author, says "You are welcome to use the GooglePlusLib.NET
client library as you like. You can use this library to develop applications
and distribute it with your applications."
The only problem
is, he only provides the downloadable Assembly and no source code is to be found.
That's not good enough for me, so I decompiled it, fixed up the code, added some XML documentation, and added a sample Test Console App that exercises some of the methods. The nice
thing about this library is that it deserializes all the API JSON into .NET Classes
which makes working with the API much cleaner. Here is some sample code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GooglePlusLib.NET;
namespace GooglePlusAPI
{
class Program
{
static string profileId = "114085939943834183247"; // Peter Bromberg
private static string apiKey = ""; // put your API Key here
static void Main(string[] args)
{
if (apiKey.Length == 0) throw new InvalidOperationException("Requires apiKey: https://code.google.com/apis/console/b/0/");
GooglePlusAPIHelper
apiHelper = new GooglePlusAPIHelper(profileId, apiKey);
// var people=apiHelper.SearchPeople("Peter Bromberg");
// var acts= apiHelper.SearchActivities("ASP.NET");
// var people apiHelper.ListPeopleByActivity();
// GPlusComments comments= apiHelper.ListComments( string
activityId);
// GPlusACtivities activities= apiHelper.ListActivities();
// GPlusPerson person= apiHelper.GetPerson();
// GPlusComment comment= apiHelper.GetComment( string commentId);
// GPlusActivity activity= apiHelper.GetActivity( string activityId);
GPlusActivities activities = apiHelper.ListActivities();
int
total = 0;
while (!string.IsNullOrEmpty(activities.nextPageToken))
{
foreach
(GPlusActivity activity in activities.items)
{
total
+= activities.items.Length;
string
titlei = activity.title;
string
plusDescription = activity.plusObject.content;
string
pubDate = activity.published.ToShortDateString();
Console.WriteLine(pubDate );
Console.WriteLine(titlei);
Console.WriteLine( plusDescription);
Console.WriteLine("===================================================================");
if (activity.plusObject.attachments == null)
continue;
foreach (Attachment
attachment in activity.plusObject.attachments)
{
if (attachment.objectType == "article")
{
string
url = attachment.url;
string
title = attachment.displayName;
string
content = attachment.content;
}
}
}
activities
= apiHelper.ListActivities(activities.nextPageToken);
foreach
(var act in activities.items)
{
Console.WriteLine( act.title);
}
}
Console.WriteLine("ITEMS:" + total.ToString());
Console.ReadLine();
}
}
}
This
library currently covers all the methods available in the Google+ API. With this
source code, you are in a position to be able to easily update it when the API
is enhanced. It also provides the nextPageToken which allows you to handle paging
of results. You have everything in this library that you need, for example, to
build an entire web site around the Google+ API including searching for people,
activities, comments, attachments (articles or images) and so on. You can get your own API key here.
You can download the full Visual Studio 2010 Solution here.