Activities with Template

0 views
Skip to first unread message

Badaro

unread,
Jun 18, 2008, 10:32:15 AM6/18/08
to Orkut Developer Forum
I'm trying to make my application send Activities using templates,
following these samples:

http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Activity
http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial.Activity.html

-------------------- BEGIN CODE --------------------

var activity = opensocial.newActivity('LISTEN_TO_THIS_SONG', {Song:
'Paint it Black',Artist: 'Rolling Stones', Subject: viewer, Owner:
owner})
opensocial.requestCreateActivity(activity,
opensocial.CreateActivityPriority.HIGH, SendActivityCallback);

-------------------- END CODE --------------------

But it always fails with the error "You must pass in an activity with
a title or title id". I can only send Activities if I don't use
templates.

Anyone has any ideas what may be causing this error?

URL for my test application:
http://189.39.44.79:8091/activitysample/activitytest.xml

Jason

unread,
Jun 20, 2008, 8:01:24 PM6/20/08
to Orkut Developer Forum
While activity templates were a part of the OpenSocial 0.7
specification, support was never added in Shindig, which is the
OpenSocial implementation that orkut, hi5, and several other
containers use for their application platforms. Furthermore, support
for 0.8 of the specification has not yet been rolled out to these
various containers since Shindig development is ongoing. You can
follow the official developer blog if you want the latest in orkut
platform-related news:

http://orkutdeveloper.blogspot.com/

For the time being, you can only specify a title and body for your
activities. To localize them, you can define all of the text you'll
need for your activities in a message bundle and use the gadgets.Prefs
instance method getMsg to retrieve the appropriate message from the
bundle (based on the user's language setting). For example, say I have
two messages defined (in separate files) for a certain greeting:

<!-- Bundle #1 (English) -->
<msg name="greeting">
Hello
</msg>

<!-- Bundle #2 (Portuguese) -->
<msg name="greeting">
Olá
</msg>

If my display language is set to Portuguese, the snippet new
gadgets.Prefs().getMsg('greeting') returns "Olá".

So the following code displays an activity with a greeting in the
language of the user who generated it:

var title = new gadgets.Prefs().getMsg('greeting');

var params = {};
params[opensocial.Activity.Field.TITLE] = title;

var activity = opensocial.newActivity( params );
opensocial.requestCreateActivity(activity,
opensocial.CreateActivityPriority.HIGH, callback);

Please let me know if you have any questions on this or if the snippet
above doesn't work for you. If you would like more details on
localization, please see the following article:

http://code.google.com/p/opensocial-resources/wiki/OrkutLocalization

Cheers!
- Jason

On Jun 18, 7:32 am, Badaro <bad...@gmail.com> wrote:
> I'm trying to make my application send Activities using templates,
> following these samples:
>
> http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial...http://code.google.com/apis/opensocial/docs/0.7/reference/opensocial....

Badaro

unread,
Jun 23, 2008, 10:43:10 AM6/23/08
to Orkut Developer Forum
Jason,

I got the information that this wasn't implemented from kurrik in the
IRC chat, and already implemented a simplified "template emulator" on
my code to solve most of my current needs.

Thanks a lot for the information on localization, currently our app is
only in portuguese, but that will likely change in the future and this
will be very helpful.
> >http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.......
Reply all
Reply to author
Forward
0 new messages