My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Message  
It is possible to send Messages. The recipients, title, and content can be specified.
jQuery.ajax, jQuery.post, jQuery.postData
en, ja
Updated Feb 26, 2010 by nakajim...@gmail.com

opensocial-0.8 is required for datatype="data" in jQuery.ajax

<ModulePrefs title="opensocial-jquery">
<Require feature="opensocial-0.8" />
</ModulePrefs>

Sending a Message

jQuery.ajax can be used to send a Message from the VIEWER

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: {
      recipients: '@owner',
      title: 'Say hello!',
      body: 'You should be shining!'
    },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });

This can also be done using jQuery.post

  $.post(
    '/messages/@viewer/@outbox', {
      recipients: '@owner',
      title: 'Say hello!',
      body: 'You should be shining!'
    },
    function() {},
    'data'
  });

The same can be done using jQuery.postData

  $.postData (
    '/messages/@viewer/@outbox', {
      recipients: '@owner',
      title: 'Say hello!',
      body: 'You should be shining!'
    },
    function() {}
  });

Specify Recipients

The recipients' parameter can be used to specify recipients. Specify one from @viewer, @owner, @viewer/@friends, @owner/@friends, or your User ID.

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: { recipients: '@viewer/@friends' },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });

Specify a Title

The title parameter can be used to specify a title.

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: { title: 'Say hello!' },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });

Furthermore, titleId can be used to specify a template ID for a title

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: { titleId: 'TEMPLATE_ID' },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });

Specify Body Text

The body parameters can be used to specify the body text.

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: { body: 'Say hello!' },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });

Moreover, bodyId can be used to specify the template ID for the body text.

  $.ajax({
    type: 'post',
    url: '/messages/@viewer/@outbox',
    data: { bodyId: 'TEMPLATE_ID' },
    dataType: 'data',
    success: function(data, status) {},
    error: function(xhr, status, e) {
      console.log('error', xhr, status, e);
    }
  });
Comment by project member rka...@gmail.com, Dec 2, 2009

mixiアプリでもrequestSendMessageが使えるようになってみたいですね。

mixi Developer Center (ミクシィ デベロッパーセンター) » ユーザにメッセージを送信してみよう http://developer.mixi.co.jp/appli/pc/lets_enjoy_making_mixiapp/send_message

上記が活用できるか試してみようと思います。

Comment by project member nakajim...@gmail.com, Dec 3, 2009

同じく試してみました。結論からいうと、使えました。

mixi がメッセージ送信 API に対応したので試してみました http://groups.google.com/group/opensocial-jquery/browse_thread/thread/b3c736d5acfa80a6


Sign in to add a comment
Powered by Google Project Hosting