Lesson 16: Request additional data from your user

From VZ Developer Wiki
Revision as of 16:17, 13 January 2011 by Bastian (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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


Lesson 15: Embed Flash and interact with the OpenSocial API Back to overview Lesson 17: Send notifications to users

In some cases you may need data which the user has not provided in the vcard he associated with your app (e.g. E-Mail or Address) or data that is not available because of your Required Fields configuration. The following example shows how to direct the user to a edit page for his vcard where he can supplement the necessary information (see also Vz.vcard#vz.vcard.update).

function onLoadUser(data) {
   var owner = data.get('owner').getData();
   if (owner.getField('emails').length === 0) {
       alert('Please enter your email address');
       vz.vcard.update(function() {
           loadUser();
       }, 'emails');
   }

   //perform operation
}

function loadUser() {
    var req = opensocial.newDataRequest();
    var params ={};
    params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
        opensocial.Person.Field.EMAILS];
    
    req.add(req.newFetchPersonRequest(opensocial.IdSpec.PersonId.OWNER,params), 'owner');
    req.send(onLoadUser);
}

loadUser();


  • Lesson 16: Request additional data from your user