Messaging¶
Sending Messages Using requestSendMessage¶
Ning actively supports OpenSocial’s requestSendMessage API, which requests Ning to send a message to a specific user or users. Rather than the application sending a standard e-mail, all messages will be directed to a section of the Ning Network’s messaging system, called alerts. A dialog box will appear for the OpenSocial Application user to confirm the message.
We previously referenced Google’s CodeRunner Application, a way to test OpenSocial APIs in real time. For this example, I am friends with one friend on a Ning Network and ran the following code:
var params = {};
params[opensocial.Message.Field.TYPE] = opensocial.Message.Type.EMAIL;
params[opensocial.Message.Field.TITLE] = "This is my test subject";
var message = opensocial.newMessage("This is a test message with some random text.", params);
// VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS or ids as a string or an array.
opensocial.requestSendMessage("VIEWER_FRIENDS", message, function(resp){
if (resp.hadError()) {
// put your error handling code here
alert('There was an error!\nResponse code: '+resp.errorCode_+'\nResponse message: '+resp.errorMessage_);
} else {
// handle successful send message logic here.
}
});
Which brings up the following dialog box:
Once the message has been sent, the person who received the message will receive the message in the alerts portion of their Inbox.
The requestSendMessage API has a quota of 35 invocations per member, per day. This means that a member can use the send message functionality 35 times per day across all apps. If a user enters multiple people in the ‘to’ field, that counts as a single invocation. The message body has a maximum character limit of 1000 characters and strips out HTML.
The requestSendMessage API has a quota of 35 invocations per member, per day. This means that a member can use the send message functionality 35 times per day across all apps. If a user enters multiple people in the ‘to’ field, that counts as a single invocation.