Viewer Orkut ID??

2 views
Skip to first unread message

Sambi Reddy

unread,
Aug 11, 2008, 8:34:31 PM8/11/08
to Orkut Developer Forum
Hi,

I am trying to retrieve Orkut of Viewer ( Viewer didn't add my
application ) using following code

--------------------------------------------------------------------------------------------------------------------------------------------------------

var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS]
= [opensocial.Person.Field.PROFILE_URL];

var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
---------------------------------------------------------------------------------------------------------------------------------------------------------

But I am not getting viewer as null.

Can anyone explain me.

Thanks,
Sambi

Fernando chucre

unread,
Aug 11, 2008, 8:42:37 PM8/11/08
to opensoci...@googlegroups.com
try

var params = {};
                       params[opensocial.DataRequest.
PeopleRequestFields.PROFILE_DETAILS]
= [opensocial.Person.Field.ID];


                       var req = opensocial.newDataRequest();
                       req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');



2008/8/11 Sambi Reddy <bsamb...@gmail.com>



--
Fernando Chucre - LPIC-1
http://www.horizontesdigitais.com

Frisoni

unread,
Aug 11, 2008, 9:00:27 PM8/11/08
to opensoci...@googlegroups.com
Hi Sambi,

your code is OK. Are you calling req.send after red.add?
Take care if you pass a function in req.send it will be executed assyncronous, so if you do like this:
function callback_function(data) {
  viewer = data.get... blablabla
}
req.send(callback_function);
alert(viewer.getDisplayName); // At this point, callback function may not yet be completed, so viewer is still Null.

You can try this code, a just checked it in Dafos: http://www.orkut.com.br/Main#AppInfo.aspx?appId=845795770537

var params = {};
params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
    opensocial.Person.Field.PROFILE_URL,

    opensocial.Person.Field.ID
];

var req = opensocial.newDataRequest();
req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
req.send(function get_callback(response) {
        viewer = response.get("viewer").getData();
        output(viewer.getField(opensocial.Person.Field.PROFILE_URL));
        output(viewer.getField(opensocial.Person.Field.ID));
  });

Hope can help you,
Frisoni

Sambi Reddy

unread,
Aug 11, 2008, 9:51:05 PM8/11/08
to Orkut Developer Forum
Hi Frisoni,

ya i am calling the req.send after the add and i made the change as
you told.

---------------------------------------------------------------------------------------------------------------------------------------------------

req.send(function getIds(response)
{
var viewer = response.get('viewer').getData();
if (viewer === null)
{
}
else
{
var profile_url =
viewer.getField(opensocial.Person.Field.PROFILE_URL);
var regex = /uid=([^&#]+)/;
var result = profile_url.match(regex);
visit_id = viewer.getId();
visit_name = viewer.getDisplayName();

if (result.length == 2)
{
var uid = result[1];
stored_uid = uid;
}
else
{
alert('There seems to be an error');
}
}

onLoadFavorites();
onLoadRecos();
});

---------------------------------------------------------------------------------------------------------------------------------------------------------------

Even after changing to the aboce code. Both the function
onLoadFavorites and onLoadRecos show visit_id as undefined but if the
user adds the application its fine.

heres the url if you want to try

http://sandbox.orkut.com/Application.aspx?appId=535756404836&uid=17158969329579561372

- Sambi


On Aug 11, 8:00 pm, Frisoni <fris...@gmail.com> wrote:
> Hi Sambi,
>
> your code is OK. Are you calling req.send after red.add?
> Take care if you pass a function in req.send it will be executed
> assyncronous, so if you do like this:
> function callback_function(data) {
>   viewer = data.get... blablabla}
>
> req.send(callback_function);
> alert(viewer.getDisplayName); // At this point, callback function may not
> yet be completed, so viewer is still Null.
>
> You can try this code, a just checked it in Dafos:http://www.orkut.com.br/Main#AppInfo.aspx?appId=845795770537
> var params = {};
> params[opensocial.DataRequest.PeopleRequestFields.PROFILE_DETAILS] = [
>     opensocial.Person.Field.PROFILE_URL,
>     opensocial.Person.Field.ID
> ];
>
> var req = opensocial.newDataRequest();
> req.add(req.newFetchPersonRequest('VIEWER', params), 'viewer');
> req.send(function get_callback(response) {
>         viewer = response.get("viewer").getData();
>         output(viewer.getField(opensocial.Person.Field.PROFILE_URL));
>         output(viewer.getField(opensocial.Person.Field.ID));
>   });
>
> Hope can help you,
> Frisoni
>
> On Mon, Aug 11, 2008 at 21:42, Fernando chucre <fernandochu...@gmail.com>wrote:
>
> > try
>
> > var params = {};
> >                        params[opensocial.DataRequest.
> > *PeopleRequestFields.PROFILE_**DETAILS]
> > = [opensocial.Person.Field.ID];*
>
> >                        var req = opensocial.newDataRequest();
> >                        req.add(req.newFetchPersonRequest('VIEWER', params),
> > 'viewer');
>
> > 2008/8/11 Sambi Reddy <bsambire...@gmail.com>

Ramanpreet Singh

unread,
Aug 12, 2008, 12:34:06 AM8/12/08
to opensoci...@googlegroups.com
Hi People.

Your are not allowed to access the viewer's object untl the viewer has
the application installed. Thats what i have been believing till now.

Sambi Reddy

unread,
Aug 12, 2008, 12:51:04 AM8/12/08
to Orkut Developer Forum
Ok,

So, you mean if viewer is null. the user don't my application
installed?

Can anyone confirm this?

Thanks Ramanpreet.
> >http://sandbox.orkut.com/Application.aspx?appId=535756404836&uid=1715...

Ramanpreet Singh

unread,
Aug 12, 2008, 1:06:40 AM8/12/08
to opensoci...@googlegroups.com
Hi.

I couldn't find a direct reference to this fact but check this,
http://developer.myspace.com/Community/blogs/devteam/archive/2008/02/05/opensocial-app-in-the-wild-dream-interpretation.aspx
, they only check for null on viewer's object, not on owner's.. will
this do to prove the fact? Plus, i have already been experiencing a
blank viewer object with users who don't have the app installed :).

You're welcome, Sambi Reddy

Reply all
Reply to author
Forward
0 new messages