notifications&feeds help !!

4 views
Skip to first unread message

mabel

unread,
Sep 24, 2008, 10:43:25 AM9/24/08
to OpenSocial - OpenSocial Application Development
Hi everybody,

I created a small application and I am trying to send users and users'
friends notifications but I failed and also I couldn't display any
activity.

Here is my code:

For notifications:

var params = {};
params[opensocial.Message.Field.TITLE]="My Game";
params[opensocial.Message.Field.TYPE]
=opensocial.Message.Type.NOTIFICATION;
var body="Tanadu";
var message = opensocial.newMessage(body, params);
var recipient = toIds;
opensocial.requestSendMessage(recipient, message,
onSendNotification);

and for activities:

var activityParams = {};
activityParams[opensocial.Activity.Field.TITLE] = 'Enjoy the
Game';

var mediaItems = new Array();
var mediaItem =
opensocial.newActivityMediaItem(opensocial.Activity.MediaItem.Type.IMAGE,
viewer.getField(opensocial.Person.Field.THUMBNAIL_URL));
// Add a media item link if supported
mediaItems.push(mediaItem);
activityParams[opensocial.Activity.Field.MEDIA_ITEMS] =
mediaItems;

var activity = opensocial.newActivity(activityParams);
opensocial.requestCreateActivity(activity,
opensocial.CreateActivityPriority['HIGH']);

Both seems correct but I couldn't find the problem. I want my app send
notification and I want to display activity on users' profile.

Any suggesstion would be appreciated. Please help if you have any
idea.

Thanks already.

api.k...@google.com

unread,
Sep 24, 2008, 2:37:59 PM9/24/08
to OpenSocial - OpenSocial Application Development
Here's code that should post a notification (OpenSocial 0.7!):

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();

Here's code that should post an activity:

function sendActivity() {
var activityParams = {};
activityParams[opensocial.Activity.Field.TITLE] =
'Test activity';

var mediaItems = new Array();
var mediaItem = opensocial.newActivityMediaItem(
opensocial.Activity.MediaItem.Type.IMAGE,
"http://www.google.com/images/logo_sm.gif");
mediaItems.push(mediaItem);
activityParams[opensocial.Activity.Field.MEDIA_ITEMS] =
mediaItems;

var activity = opensocial.newActivity(activityParams);
opensocial.requestCreateActivity(activity, "HIGH",
onActivitySent);
};

function onActivitySent(data) {
if (data.hadError()) {
alert("Could not send activity update: " +
data.getErrorMessage());
} else {
alert("The Activity was sent");
}
};

sendActivity();


If these don't work, let me know what container you're working on-
activities or notifications may not be supported.

~Arne

halosys

unread,
Oct 6, 2008, 6:56:56 AM10/6/08
to OpenSocial - OpenSocial Application Development
HI,

Thanks for suggestion.

I tried the code to send activity update.
But could not see any image in updates in my account.

I want to display image of sender and receivers in update activity
when a form is posted in my gadget .
I am using mozilla5.0 and IE 6.0 for testing same.


Thanks,


Manoj
>   varmediaItem= opensocial.newActivityMediaItem(
Reply all
Reply to author
Forward
0 new messages