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
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
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.
18.227.79.241