Hi Peter. Yoichiro is absolutely right -- I just wrote a quick sample and this worked for me:
var viewer = data.get('viewer_profile').getData(); var addresses = viewer.getField(opensocial.Person.Field.ADDRESSES); for (var i=0; i<addresses.length; i++) { alert(addresses[i].getField(opensocial.Address.Field.LOCALITY)); } Keep in mind that you will only be able to access the viewer's addresses if he/she has the application installed. Otherwise, this field will always be null. It's also a good idea to do some rudimentary error checking before outputting anything in production. This way you can recover more gracefully if something unexpected happens. For example, I could do something like this with my snippet above: ... if (addresses.length) { for (var i=0; i<addresses.length; i++) { if (opensocial.getEnvironment().supportsField(opensocial.Environment.ObjectType.ADDRESS, opensocial.Address.Field.LOCALITY)) { alert(addresses[i].getField(opensocial.Address.Field.LOCALITY)); } } } Cheers! - Jason On Jun 29, 11:10 pm, yoichiro <[EMAIL PROTECTED]> wrote: > Hi Peter, > > On Jun 30, 1:55 pm, Peter <[EMAIL PROTECTED]> wrote: > > > var address = viewer.getField(opensocial.Person.Field.ADDRESSES); > > var country = address.getField(opensocial.Address.Field.COUNTRY); > > output(country) > > You might be receiving two or more result as Array<Address> because > the Person model can have one or more addresses. And you should > consider the way to process them if there are two addresses or more. > > var addresses = viewer.getField(opensocial.Person.Field.ADDRESSES); > var cnt = addresses.length; > if (cnt == 0) { > // Processing when user has no address.} else if (cnt == 1) { > > var address = addresses[0]; > var country = address.getField(opensocial.Address.Field.COUNTRY); > output(country);} else { > > // Processing when user has two or more addresses. > > } > > Best regards, > Yoichiro --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Orkut Developer Forum" group. To post to this group, send email to opensocial-orkut@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-orkut?hl=en -~----------~----~----~----~------~----~------~--~---