opensocial
- Method
- opensocial.requestSendMessage
- opensocial.requestShareApp
- opensocial.requestCreateActivity
- opensocial.hasPermission
- opensocial.requestPermission
- opensocial.getEnvironment
- opensocial.newDataRequest
- opensocial.newActivity
- opensocial.newMediaItem
- opensocial.newMessage
- opensocial.newIdSpec
- opensocial.newNavigationParameters
Method
opensocial.requestSendMessage
<static> requestSendMessage(recipients, message, opt_callback, opt_params)
Makes a request for a message to be sent to the specified user.
Parameters
| Name | Type | Description |
|---|---|---|
| recipients | String | Refer to the group or User ID of the receiver. Only the OWNER key is supported. |
| message | opensocial.Message | Message object sent to the specified user |
| opt_callback | Function | The callback function that is called when the request is complete |
| opt_params | opensocial.NavigationParameters | The parameters that indicate the location the user is moved to when requested, or when a request is accepted |
Return value
None
Sample
var params = {};
params[opensocial.Message.Field.TITLE] = "Hello!";
var msg = opensocial.newMessage("Hello!", params);
var recipient = "xxxxxx";
opensocial.requestSendMessage(recipient, msg,
function (res) {
if (res.hadError()) {
// ...
} else {
// ...
}
}
);
opensocial.requestShareApp
<static> requestShareApp(recipients, reason, opt_callback, opt_params)
Makes a request for this application to be shared with the specified user.
Parameters
| Name | Type | Description |
|---|---|---|
| recipients | String | Only VIEWER_FRIENDS can be specified |
| reason | null | null |
| opt_callback | Function | The callback function that is called when the request is complete |
Return Value
None
Sample
var params ={};
params[opensocial.Message.Field.TITLE] = "invite to new Game";
var msg =opensocial.newMessage("Let's play together!in campaign now!", params);
opensocial.requestShareApp("VIEWER_FRIENDS", msg,
function(res) {
if (res.hadError()) {
// ...
} else {
// ...
}
}
);
opensocial.requestCreateActivity
<static> requestCreateActivity(activity, priority, opt_callback)
Makes a request to create the specified activity without waiting for the operation to be completed.
Parameters
| Name | Type | Description |
|---|---|---|
| activity | opensocial.Activity | Activity object to be created |
| priority | opensocial.CreateActivityPriority | Request Priority |
| opt_callback | Function | The callback function that is called when the request is complete |
Return Value
None
Sample
var params = {};
params[opensocial.Activity.Field.TITLE] = "Hello!";
var activity = opensocial.newActivity(params);
opensocial.requestCreateActivity(activity, opensocial.CreateActivityPriority.LOW,
function(res) {
if (res.hadError()) {
// ...
} else {
// ...
}
}
);
opensocial.hasPermission
Not supported
opensocial.requestPermission
Not supported
opensocial.getEnvironment
Not supported
opensocial.newDataRequest
<static> opensocial.DataRequest newDataRequest()
Create a DataRequest object
Parameters
None
Return Value
| Type | Description |
|---|---|
| opensocial.DataRequest | New DataRequest Object |
Sample
var req = opensocial.newDataRequest();
opensocial.newActivity
<static> opensocial.Activity newActivity(params)
Creates an Activity object
Parameters
| Name | Type | Description |
|---|---|---|
| params | Map.<opensocial.Activity.Field/Object> | Other fields that must be set as the Activity object. opensocial.Activity.Field.TITLE can be specified. |
Return Value
| Type | Description |
|---|---|
| opensocial.Activity | Activity object |
Sample
var params = {};
params[opensocial.Activity.Field.TITLE] = "Hello!";
var activity = opensocial.newActivity(params);
opensocial.newMediaItem
<static> opensocial.MediaItem newMediaItem(mime_type, url, opt_params)
Creates a MediaItem object
Parameters
| Name | Type | Description |
|---|---|---|
| mime_type | String | Media MIME type |
| url | String | Media URL |
| opt_params | Map.<opensocial.MediaItem.Field/Object> | Other fields that must be set as the MediaItem object |
Return Value
| Type | Description |
|---|---|
| opensocial.MediaItem | MediaItem object |
Sample
var mediaItem = opensocial.newMediaItem("image/gif", "http://example.com/foo.gif");
opensocial.newMessage
<static> opensocial.Message newMessage(body, opt_params)
Description
Create a Message object
Parameters
| Name | Type | Description |
|---|---|---|
| body | String | Main text of the message |
| opt_params | Map. | Other fields that must be set as the Message object |
Return Value
| Type | Description |
|---|---|
| opensocial.Message | Message object |
Sample
var params = {};
params[opensocial.Message.Field.TITLE] = "Hello!";
var message = opensocial.newMessage("こんにちは!", params);
opensocial.newIdSpec
<static> opensocial.IdSpec newIdSpec(parameters)
Description
Create an IdSpec object
Parameters
| Name | Type | Description |
|---|---|---|
| patameters | Map.<opensocial.IdSpec.Field/Object> | Other fields that must be set as the IdSpec object |
Return Value
| Type | Description |
|---|---|
| opensocial.IdSpec | IdSpec object |
Sample
var params = {};
params[opensocial.IdSpec.Field.USER_ID] = opensocial.IdSpec.PersonId.VIEWER;
params[opensocial.IdSpec.Field.GROUP_ID] = opensocial.IdSpec.GroupId.FRIENDS;
var id_spec = opensocial.newIdSpec(params);
opensocial.newNavigationParameters
Not supported
Revision History
- 01/24/2011
- Modified the opensocial.requestSendMessage sample.
- 12/2010
- Initial Release.