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 <[EMAIL PROTECTED]>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
> [EMAIL PROTECTED]
>