Introduction

One of the article's goals is introduction of OpenSocial to ASP.NET developers. I hope it can help you to answer the questions like "how I can build my own social network using ASP.NET" or "how to provide the way to extend my ASP.NET site by third-party developers". The second goal is introducing of my custom implementation of OpenSocial specification.

What is OpenSocial?

OpenSocial is a specification that defines a browser-based component model, known as gadgets, and an API for accessing information about user profile information and social graphs, including friends and activities. Applications that use the OpenSocial APIs can be embedded within a social network itself, or access a site’s social data from anywhere on the web. [Sources: Wikipedia and Opensocial.org]
Here’s another definition: At it’s most simplified, OpenSocial is able to offer up bits of user interface from one application, while embedding them in another application, exchanging information along with it. [1]

OpenSocial Data Server: an implementation of the server interface to container-specific information, including the OpenSocial REST APIs, with clear extension points so others can

Apache Shindig is the reference implementation of OpenSocial API specifications, versions 1.0.x and 2.0.x, a standard set of Social Network APIs which includes:

Profiles

Relationships

Activities

Shared applications

Authentication

Authorization

There are two implementation of Shindig available:

Java

PHP

What’s about .NET implementation?

Unfortunately, there are no production ready .NET implementations. See this question at stackoverflow. Briefly, there are few existing implementation and all of the are out of date and cannot be easily integrated into existing ASP.NET applications.

Negroni: render engine

Pesta: line by line port of java version of shindig

How does OpenSocial gadget look like?

OpenSocial Gadgets - simple HTML and JavaScript applications that can be embedded in webpages and other apps. Gadgets are developed using the OpenSocial Gadgets API and basic web technologies such as XML, JavaScript, Flash. Typical gadget can look like the picture below:

Description contains various information about gadget, e.g.:

Author

Title

Thumbnail icon

This information can be used by container.

Locale element specifies the locales, or regional language types, supported within the gadget. There may be many Locale nodes within a single gadget if it supports many
international countries and languages.

Require (must include) and Optional (may include if available) elements denote feature dependencies to be made available to a gadget. A Feature is a set of processing instructions and JavaScript libraries that provides some specific functionality for a gadget. Examples:

Content section contains the run time portion of the gadget – view. The view consists of HTML, CSS and Javascrip. Different views have different characteristics. For example, a container might have a view that shows gadgets in a small format, and a view that shows gadgets in full page format. There are exmples:

default — the standard view of a gadget, displayed in a small box on the page, possibly with other gadgets.

canvas — the maximised view of a gadget when displayed by itself on the page.

OpenSocial gadget examples

Render friends with templating and pipelining

This example demonstrates how to render friend list using opensocial templating and data pipelining.

Explore opensocial with ASP.NET and Catpic

Catpic is OpenSocial Container for .NET developers that provides extensible component hosting environment and social facilities to existing .NET applications using best practices. It is OpenSource project which is open for participation. In general, Catpic uses Shindig's client-side code and consists of the following parts:

OpenSocial Container: implementation of the public specification that defines a component hosting environment (container) and a set of common application programming interfaces (APIs) for social networking web-based applications

Gadget Rendering Server: used to render the gadget XML into JavaScript and HTML for the container to expose via the container JavaScript. This part is written on .NET and common modules can be replaced/extended by custom ones.

EntityFramework library is required by Catpic.Data.EntityFramework library which uses Code First approach of EF to store information into MS SQL Server. You can safely remove it if you want to implement your custom implementation of data layer. Example site uses static json file by default.

The easiest way to use catpic is usage of dependency injection containers. Nuget package provides default classes which use Unity as DI container. If you want to use different DI, just provide your implementation of Catpic.Web.Configuration.IHostContainer interface

Add gadget to view

This example demonstrate how to render gadget using shindig client-side API. Result:

You can use different approach to render gadgets: just create iframe with src:

http://localhost/gagdets/ifr?url=gadget_url

Where gadget_url - gadget’s url

Render OpenSocial gadgets

Demo application uses fake repository of shindig: canonicaldb.json file. Currently Catpic provides the implementation of repositories for people, messages, activitystreams services by Catpic.Data.EntityFramework library which contains logic to store social data into MS SQL Service database using Code First approach of EntityFramework.
Here are short examples:

User profile

User's friends

Catpic demo site

Example above demonstrates only few aspects of catpic implementation of opensocial container. You can checkout Catpic sources and explore more. It is available here:

Comments and Discussions

I am investigating a port of our portal based on an earlier version of Java shindig to .NET. We almost entirely use shindig for gadget rendering and and client APIs for makeRequest, but really none of the OpenSocial features (activity list, member-to-member relationships, etc.) Is this a framework something we should investigate further, or would rolling our own system using Negroni a better way to go?

I guess Negroni would be better for production as it was developed by myspace team (not a single developer). However, it seems like it contains some myspace-specific html code hardcoded in csharp files.