Sending private messages on Friendster

| | Comments (0) | TrackBacks (0)
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:

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

0 TrackBacks

Listed below are links to blogs that reference this entry: Sending private messages on Friendster.

TrackBack URL for this entry: http://roomanna.com/mt-tb.cgi/5

Leave a comment

About this Entry

This page contains a single entry by Arne Roomann-Kurrik published on September 24, 2008 11:09 AM.

Fetch by ID sample was the previous entry in this blog.

Presentation from DevFest Beijing is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.