Link

The Link element allows a developer to take advantage of application life-cycle events defined by a container. Such events might be application installs or uninstalls, or any other event in the day-to-day life of a social application. The container supports these features by sending relevant query parameters denoting the event to a URL endpoint specified within the Link node.

A Link node may take the following form under the ModulePrefs element:

<ModulePrefs>
    <Link rel="event" href="http://www.mysite.com/ping.php" method="POST" />
    <Link rel="event.addapp" href="http://www.mysite.com/add_app.php" />
    <Link rel="event.removeapp" href="http://www.mysite.com/remove_app.php" />
</ModulePrefs>

As you can see in the preceding example, the Link node has several associated attributes. They are listed in Table 3-5.

Table 3-5. Link attributes

Attribute

Description

rel

The string value that denotes the event being triggered. This value is required.

href

The URL to make a request to once the event has been triggered. This value is required.

method

The HTTP request method, either GET or POST, to use when making a request to the URL supplied in the href attribute. The default request method is GET. This is an optional attribute.

If a Link node is specified with a rel of opensocialevent (e.g., rel="event"), then any undefined life-cycle event types will be sent through to that href value by default. If there are one or more Link nodes with a rel of opensocialevent.type (e.g., rel="event.addapp"), then any container life-cycle event with a matching type will be forwarded on to the href value specified in that node.

As shown in Table 3-6, there are currently four event types defined within the OpenSocial specification, which developers can use to handle life-cycle events.

Table 3-6. OpenSocial event types

Event

Description

addapp

Event triggered when one or more users install the application. The parameters attached with the event are:

id

Unique ID that identifies the users who have installed the application.

from

Identifies how the users installed the application. Defined values are invite, gallery, or external. This parameter is optional.

removeapp

Event triggered when one or more users uninstall the application. The parameters attached with the event are:

id

Unique ID that identifies the users who have uninstalled the application.

app

Event triggered when the developer or container changes the application state. The parameters attached with the event are:

action

The action performed on the application to change its state. Defined values are enabled, disabled, or approved.

reason

The reason that the action was taken. Defined values are policy, quota, or maintenance. This parameter is optional.

invite

Event triggered when someone has invited other users to install the application. The parameters attached with the event are:

id

Unique ID that identifies the users who have been invited to the application.

from_id

Unique ID that identifies the user who sent the application invitation.

The value of supporting life-cycle event notifications through tools such as Link nodes cannot be stressed enough. Having an up-to-date database of user records and links that is in sync with the actual application use on the container is vital for maintaining a high-performance, targeted service. This is a low-cost measure for containers, but even more importantly, both the container and the gadget developer reap the benefits of offering applications with a greater degree of user control, making this a win-win situation.

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

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