Understanding the OpenSocial API

What is OpenSocial? Simply put, OpenSocial defines a common Application Programming Interface (API) for social applications across multiple social networking websites. In essence, you use the OpenSocial API to build hosted XML applications/documents written in HTML and JavaScript. The API lets your applications access the network’s friends and update feeds.

Note

Learn more about developing Google gadgets in Chapter 44, “Creating Google Gadgets.”

OpenSocial applications can be written in any HTML or text editor, or using the Google Gadgets framework. In fact, creating an OpenSocial application is a lot like creating a Google gadget.

Note

Learn more about OpenSocial at the OpenSocial Foundation website (www.opensocial.org). The OpenSocial Foundation is a not-for-profit entity jointly proposed by Google, MySpace, and Yahoo!

The nice thing about the OpenSocial API is that you no longer have to develop separate applications for each social network. The API is cross-network compatible, so the apps you develop for one network should easily port to other OpenSocial networks.

There are actually four different APIs within the general OpenSocial API:

  • Activities API, used for publishing and accessing information about user activities.

  • JavaScript API, used to interface with JavaScript-based social data.

  • People and Friends API, used to access people and relationship data.

  • Persistence API, used for server-free stateful applications.

Examining OpenSocial Compatibility

OpenSocial was developed by Google, Yahoo!, MySpace, and other popular social networks. The OpenSocial API was released on November 1, 2007, and already hundreds of OpenSocial applications are available.

OpenSocial Sites

Which sites currently or plan to support OpenSocial apps? Here’s the list as of Fall 2008:

Note

Oracle, Salesforce.com, and Six Apart also support OpenSocial on their respective web platforms. In addition, Yahoo! is also part of the OpenSocial alliance, and is likely to support OpenSocial when its Mash social network moves out of the testing phase.

Notice any social networking sites missing from this list? The big one, of course, is Facebook, which is defiantly not part of the OpenSocial alliance. In fact, OpenSocial is regarded in part as a cross-platform alternative to the Facebook platform. So, if you develop OpenSocial apps, you’ll won’t be able to port them to Facebook; your Facebook apps will have to continue to be built from scratch, using that site’s native developer tools.

OpenSocial Applications

What types of OpenSocial applications are available? Companies currently offering OpenSocial applications include the following:

Figure 45.1. The Flixter application on MySpace.

The Flixter application on MySpace.

Figure 45.2. The RockYou slideshow on MySpace.

The RockYou slideshow on MySpace.

Developing with the OpenSocial API

If you want to develop your own OpenSocial applications, the place to start is the Google Code OpenSocial gateway (code.google.com/apis/opensocial), shown in Figure 45.3. From here, you can read the OpenSocial documentation, download the OpenSocial API, converse with other developers on the OpenSocial blog, and start developing your own OpenSocial apps.

Figure 45.3. The Google Code OpenSocial gateway.

The Google Code OpenSocial gateway.

Tip

Find more OpenSocial applications at the OpenSocial Directory (www.opensocialdirectory.org).

As noted previously, OpenSocial applications are built on the Google gadget model. This means that you can develop your social apps with little or no serving costs, using the Google Gadget Editor. Naturally, you first have to register and obtain your API key/value, which then goes in all your app code. This is all explained on the Google Code site.

Before you start developing your application, you have to pick one of the compatible social networks as your code/testing base. This will be the main network for your application; this base code can then be ported to other OpenSocial sites.

At its core, a social application is an XML gadget file. The code is actually quite straightforward, as you can see in this simple example:

<?xml version="1.0" encoding="UTF-8" ?>
<Module>
  <ModulePrefs title="title">
    <Require feature="opensocial-0.7" />
  </ModulePrefs>
  <Content type="html">
    <![CDATA[
          // Your code here...
    ]]>
  </Content>
</Module>


There are six main sections to the OpenSocial application code, as detailed in Table 45.1.

Table 45.1 OpenSocial Gadget Code

Image

You can use any text editor or HTML editor to create this code. Alternatively, you can develop the code using the Google Gadget Editor. To run, the code must be uploaded to a website host; again, you can use the Google Gadget Editor for this.

You’ll also need an account at the social network site for which you’re writing. You can then use that site’s developer’s sandbox. Within the sandbox, you’ll need to supply the URL where the application is stored; you’re then prompted to authorize the application to access your profile, friends, activity stream, and the like. This installs the application on your page on that social networking site.

Note

Learn more about the Google Gadget Editor in Chapter 43, “Using Google’s APIs and Developer’s Tools.”

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.50.252