I had to write a quick sample today to send a private message to the OWNER on Friendster. The following sends a message to your Friendster message inbox:
Also note that this is for OpenSocial 0.7. If you're migrating this code to another container on 0.8, you'll need to change the IdSpec stuff (as I've covered before).
function sendNotification() {
var params = {};
params[opensocial.Message.Field.TITLE] =
"Title of the notification goes here";
params[opensocial.Message.Field.TYPE] =
opensocial.Message.Type.PRIVATE_MESSAGE;
var body="Text of the notification goes here";
var message = opensocial.newMessage(body, params);
var recipient = opensocial.DataRequest.PersonId.OWNER;
opensocial.requestSendMessage(recipient, message,
onSendNotification);
};
function onSendNotification(resp) {
if (!resp.hadError() && resp.getData().status == "sent") {
alert("The message was sent to the OWNER");
} else {
alert("There was a problem: " + resp.getErrorMessage());
}
};
sendNotification();
Note the message type is set to PRIVATE_MESSAGE. Friendster also supports type NOTIFICATION, but I haven't quite figured out where that shows up, and I get a "Insufficient permissions for action 'publicMessage'" error message when trying PUBLIC_MESSAGE.Also note that this is for OpenSocial 0.7. If you're migrating this code to another container on 0.8, you'll need to change the IdSpec stuff (as I've covered before).

Leave a comment