Lesson 22: Posting a status update for an user

From VZ Developer Wiki
Jump to: navigation, search

General Guidelines | XML Specification | Features | Views | JavaScript API | REST API | Tutorials | OAuth


Lesson 21: Interacting with an additional IFrame Back to overview Lesson 23: Connecting to an external API with OAuth authorization

To post a status update on behalf of the user into the users activity feed you have to call the opensocial.requestCreateActivity method with the activity that should be posted.

Before the activity is sent into the feed has to confirm this with a platform dialog.

var params = [];
params[opensocial.Activity.Field.BODY ] = 'my status update';
        
var activity = opensocial.newActivity(params);

opensocial.requestCreateActivity(activity, null, function(submitted) {
    console.log('submitted :', submitted);
});

Of course you can embed an embed view of your gadget or any static content you defined in your static_content.json file in your message. These links will be automatically replaced by the content or the gadget via an internal OEmbed resource. Please keep in mind that the activity body has a maximum length of 140 characters. Also if there is more than one embeddable URL present, only the first URL will be resolved and displayed.


vz.embed.getEmbedUrl({name: 'world'}, function(embedUrl) {
    var params = [];
    params[opensocial.Activity.Field.BODY ] = 'my status update';
    params[opensocial.Activity.Field.URL ]  = embedUrl;
    var activity = opensocial.newActivity(params);
    opensocial.requestCreateActivity(activity, null, function(submitted) {
        console.log('submitted :', submitted);
    });
});

The maximum area of the embed view within an status update is 400x90px.


  • Lesson 22: Posting a status update for an user