Hi Murali,

Looks like you are trying to get the VIEWER ID. You can get the viewer
object with the following snippet.

function requestMe() {
  var req = opensocial.newDataRequest();
  req.add(req.newFetchPersonRequest(

            opensocial.IdSpec.PersonId.VIEWER),
          "viewer");
  req.send(handleRequestMe);
};

function handleRequestMe(data) {
  var viewer = data.get("viewer");
  if (viewer.hadError()) {

    *//Handle error using viewer.getError()...*
    return;
  }

  *//No error. Do something with viewer.getData()...*
}

Search for viewer.getData() function. This might be useful too
(http://code.google.com/apis/opensocial/docs/0.8/devguide.html)


Ok, I am new to opensocial and haven't written a single gadget yet. So
people correct me if I am wrong.

Thanks
Binesh Gummadi

On Fri, May 8, 2009 at 3:20 AM, <[email protected]> wrote:

>
> Thanks for the reply balaji. But my requirement is different. I need to
> get the loggedIn userId. Is there any google API methods for getting the
> userId.
>
>
> Regards,
> Pinky Muralidhar.
>
> -----Original Message-----
> From: Balaji Srinivasan [mailto:[email protected]]
> Sent: Friday, May 08, 2009 10:37 AM
> To: [email protected]
> Subject: Re: Getting userId from the gadget.
>
> Hi PinkyThere are two types of users associated with an opensocial
> gadget.
> The viewer and owner. The viewer is one who is viewing the gadget (think
> of you viewing someone elses profile page where he/she has installed a
> gadget).
> The owner is the person who has installed the gadget.
>
> http://code.google.com/apis/opensocial/docs/0.8/reference/#opensocial.Da
> taRequesthas
> a snippet of how to get the viewer of a gadget. You can replace the
> token VIEWER by OWNER to get the person who owns the page
>
> In the response method, you can do getId on the person object to get the
> ID.
> Balaji
>
> On Thu, May 7, 2009 at 9:48 PM, <[email protected]> wrote:
>
> > Hi All,
> >
> >    I wanted to know is there any way to get the userId from the
> gadget.
> > Help will be appreciated
> >
> > Regards,
> > Pinky Muralidhar.
> >
> >
> > Please do not print this email unless it is absolutely necessary.
> >
> > The information contained in this electronic message and any
> > attachments to this message are intended for the exclusive use of the
> > addressee(s) and may contain proprietary, confidential or privileged
> > information. If you are not the intended recipient, you should not
> > disseminate, distribute or copy this e-mail. Please notify the sender
> > immediately and destroy all copies of this message and any
> attachments.
> >
> > WARNING: Computer viruses can be transmitted via email. The recipient
> > should check this email and any attachments for the presence of
> > viruses. The company accepts no liability for any damage caused by any
>
> > virus transmitted by this email.
> >
> > www.wipro.com
> >
>
> Please do not print this email unless it is absolutely necessary.
>
> The information contained in this electronic message and any attachments to
> this message are intended for the exclusive use of the addressee(s) and may
> contain proprietary, confidential or privileged information. If you are not
> the intended recipient, you should not disseminate, distribute or copy this
> e-mail. Please notify the sender immediately and destroy all copies of this
> message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient
> should check this email and any attachments for the presence of viruses. The
> company accepts no liability for any damage caused by any virus transmitted
> by this email.
>
> www.wipro.com
>

Reply via email to