You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Akash Xavier <ak...@gmail.com> on 2008/07/25 18:39:52 UTC
Getting the Viewer ID
I used the following code to get the viewer's ID
function request_viewerID() {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER,
'hashKey'));
req.send(callback);
};
function callback(obj) {
var viewer = data.get('hashKey').getData();
return viewer
};
viewerID=request_viewerID()
alert(viewer);
But it doesn't work. Is there anything wrong with the code?
And I also how can I detect which view the app is being run on? (gadget or
profile or cavas or whatever)?
--
Akash Manohar
akashmanohar@gmail.com
Re: Getting the Viewer ID
Posted by David Byttow <da...@google.com>.
Hi Akash,
If you are receiving a bad response, check to make sure that you're calling
req.add correctly. req.add takes two parameters (the constructed request
object and the key id), not newFetchPersonRequest:
req.add(req.newFetchPersonRequest(
opensocial.DataRequest.PersonId.VIEWER), 'hashKey');
Also, are a number of other things incorrect. Here's a quick snippet of what
I think you're trying to do:
function requestViewerId(callback) {
var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
req.send(callback);
}
requestViewerId(function(response) {
var viewer = response.get('viewer').getData();
var id = viewer.getId();
alert(id);
});
Hope this helps!
David
On Fri, Jul 25, 2008 at 9:39 AM, Akash Xavier <ak...@gmail.com>wrote:
> I used the following code to get the viewer's ID
>
> function request_viewerID() {
> var req = opensocial.newDataRequest();
>
> req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER,
> 'hashKey'));
> req.send(callback);
> };
>
> function callback(obj) {
> var viewer = data.get('hashKey').getData();
> return viewer
> };
>
> viewerID=request_viewerID()
> alert(viewer);
>
> But it doesn't work. Is there anything wrong with the code?
>
> And I also how can I detect which view the app is being run on? (gadget or
> profile or cavas or whatever)?
>
>
> --
> Akash Manohar
> akashmanohar@gmail.com
>
Re: Getting the Viewer ID
Posted by Adriano Crestani <ad...@apache.org>.
Hi Akash,
what is happening? is it returning a null value for the viewer?
try to use the gadgets.views.getCurrentView() to retrieve the current view :
)
Regards,
Adriano Crestani
On Fri, Jul 25, 2008 at 8:39 AM, Akash Xavier <ak...@gmail.com>
wrote:
> I used the following code to get the viewer's ID
>
> function request_viewerID() {
> var req = opensocial.newDataRequest();
>
> req.add(req.newFetchPersonRequest(opensocial.DataRequest.PersonId.VIEWER,
> 'hashKey'));
> req.send(callback);
> };
>
> function callback(obj) {
> var viewer = data.get('hashKey').getData();
> return viewer
> };
>
> viewerID=request_viewerID()
> alert(viewer);
>
> But it doesn't work. Is there anything wrong with the code?
>
> And I also how can I detect which view the app is being run on? (gadget or
> profile or cavas or whatever)?
>
>
> --
> Akash Manohar
> akashmanohar@gmail.com
>