JavaScript API Overview (v0.8)
From OpenSocial
Contents |
This page covers some of the major areas of the OpenSocial JavaScript API.
Requesting Data
Apps can ask the container for social data, like a user's name or photo, by sending a DataRequest. Apps can also request content from other servers by using the makeRequest function.
Social Data
To request social data, first create a new opensocial.DataRequest, add request items to it, and send it to the container.
When the container has processed your request, the callback method you provided to the send() function will be invoked with an opensocial.DataResponse as the only parameter.
- Related Classes and Functions
- opensocial.DataResponse
- opensocial.ResponseItem
- opensocial.Collection
Remote Data
To send a HTTP request to another server, use gadgets.io.makeRequest. There are a number of optional parameters you can send to the makeRequest function to control the content of the request and the response.
Person Objects and Fields
A user's profile data is contained in an opensocial.Person object. Some profile fields are represented by classes to preserve the structure of the data.
Viral Channels
OpenSocial defines three ways for your app to spread between users: activities, messages, and invitations.
Activities
When a user performs an action within your app, you can post this as an activity so the user's friends can see what they're up to.
- Related Classes and Functions
- opensocial.requestCreateActivity()
- opensocial.newMediaItem()
- opensocial.Activity
- opensocial.CreateActivityPriority
- opensocial.MediaItem
Messages
Sometimes users want to share info with a specific friend (or group of friends) by sending messages.
- Related Classes and Functions
- opensocial.requestSendMessage
- opensocial.Message
Invitations
If a user really likes your app, you can let them share it with their friends.
- Related Classes and Functions
- opensocial.requestShareApp
- opensocial.NavigationParameters
Capability Discovery
Not all containers support the same functionality or profile fields, so OpenSocial provides a way for your app to discover what is available.
Profile Field Support
You can ask the container if it supports a specific profile field (e.g. movies, interests, etc.)
- Related Classes and Functions
- opensocial.getEnvironment
- opensocial.Environment
Feature Support
You can ask the container if it support a specific feature (e.g. tabs, views, etc.)
- Related Classes and Functions
- gadgets.util.hasFeature()
- gadgets.util.getFeatureParameters()
Permissions
You can ask the ocntainer if your app has permission to perform an action (e.g. post activity, send message, etc.)
- Related Classes and Functions
- opensocial.requestPermission
- opensocial.hasPermission
- opensocial.Permission
|
OpenSocial 0.8 |
|||
