Hi

 I have to send invitation to my hosting application friends from my
opensocial application. To implement this, I found that opensocial
provides a method requestSendMessage(), first thing this method was
not sending messages, I tried with my own account and it allows only
10 invocations per day. I tried to use the
opensocial.Person.Field.EMAILS but its showing undefined as the
result. Could any one please tell me whats the wrong in my code.

Here is my code snippet that gets the list of friends and the owners
email id(iam trying to retrieve for the moment the owners email id for
testing purposes) and I also posted the method that uses
requestSendMessage() if it allows more than 10 invocations, i will
this.

/*Request for friends information*/
function getFriends()
{
 var params= {};
 params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] =
[opensocial.Person.Field.EMAILS];

 //params[opensocial.DataRequest.DataRequestFields.ESCAPE_TYPE] =
[opensocial.EscapeType.NONE];

 var req = opensocial.newDataRequest();
 //req.add(opensocial.Email.Field.ADDRESS,params);
 
req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.OWNER,params),
'owner');
 
req.add(req.newFetchPeopleRequest(opensocial.DataRequest.Group.OWNER_FRIENDS),
'ownerFriends');
 req.send(onLoadFriendsData);
};
/*dataResponse Friend information that was requested*/
function onLoadFriendsData(dataResponse)
{
    var owner = dataResponse.get('owner').getData();
  // var email = owner.getField(opensocial.Person.Field.EMAILS); 1
  var email = owner.getField(opensocial.Person.Field.EMAILS)
[0].getField(opensocial.Email.Field.ADDRESS);
 alert(email);
 var html = 'List of your Friends : '+ ' <a
href=javascript:CloseFriendsDiv()>Close</a>';
 html += '<br><ul>';
 var ownerFriends = dataResponse.get('ownerFriends').getData();
 ownerFriends.each(function(person) {
   html += '<li>' + person.getDisplayName() + '</li>';
 });
 html += '</ul>';
 document.getElementById('friendsList').style.display = '';
 document.getElementById('friendsList').innerHTML = html;
};
function sendEmail()
{
  var params = [];

  var subject = "";
  var tbSubjectCtrl = document.getElementById('tbSubject');
  if(tbSubjectCtrl != null)
  {
    subject = tbSubjectCtrl.value;
  }
  params[opensocial.Message.Field.TITLE]= subject;

  var body="";
  var tbMessageCtrl = document.getElementById('tbMessage');
  if(tbMessageCtrl != null)
  {
    body = tbMessageCtrl.value;
  }
  var message = opensocial.newMessage(body, params);

  var recipient = opensocial.DataRequest.PersonId.OWNER;
  alert(recipient + ' ' + message);
  opensocial.requestSendMessage(recipient, message);
};

Any Ideas would be appreciated!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"OpenSocial Application Development" group.
To post to this group, send email to opensocial-api@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/opensocial-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to