Accessing user data from server-side

6 views
Skip to first unread message

Den

unread,
Nov 20, 2007, 10:32:53 AM11/20/07
to OpenSocial - OpenSocial API Definition
Hi.
I'm newbie to opensocial. I have a great challenge.

ok, I have developed applications for facebook, and I can't understand
one thing in opensocial.

I want to build and application that will be working on a remote
server with server-side scripting (it will be quite complex
application, so client JavaScript is not enough). It will be installed
to the user's profile and will let him do some cool things.

Two big issues:
1. I want to make it multi-paged (I will have several sections in this
application, like "about", "help", "main" and so on) How do I do this?
Should all my links to pages be implemented as AJAX requests to my
server?
2. How do I retrieve user data from my server? Does opensocial send me
some session tokens? Client side functionality (opensocial javascript
namespace) is quite easy, but how do I do the same within my PHP
scripts?

Thanks a lot in advance.
P.S. Sorry for my stupid questions :)

Thanks,
Den.

Arne Roomann-Kurrik (Google)

unread,
Nov 20, 2007, 4:27:35 PM11/20/07
to OpenSocial - OpenSocial API Definition
Hi Den,

Orkut allows for passing data through the querystring to your gadget.
Any querystring parameters prefixed with "up_" are automatically
passed to your application, so people have implemented paging through
links like

http://sandbox.orkut.com/Application.aspx?appId=<your_application_id>&up_path=about

Inside your app, you can check _args()["up_path"] to get the value (in
this case, it would be "about") and decide which page to show based
off of this value.

To create a url programatically, you need to get the app ID number.
There isn't a specific method to get this in the API yet, but you can
get the App ID by requesting an activitystream for a user:

http://code.google.com/apis/opensocial/docs/javascript/reference/opensocial.Stream.Field.html#APP_ID

You would make a newFetchActivitiesRequest and call
getField(opensocial.Stream.Field.APP_ID)); on the object that is
returned to get this value.


For your second question, we haven't released the Data APIs yet - once
we do, you'll be able to work with data directly on your server.

~Arne

Den

unread,
Nov 21, 2007, 1:47:17 AM11/21/07
to OpenSocial - OpenSocial API Definition
Thanks for reply.

I have several questions again.

I have tried using up_path parameter, but my application doesn't
receive any querystring parameter.
My link was: http://sandbox.orkut.com/Application.aspx?uid=17918730883118925891&appId=426648787570&bpc=1&up_path=test

Btw, bpc=1 - is needed to disable caching. If it is enabled - my
application is not being queried directly on my server, but will be
executed from the cache. It can't be that if I'm working with
interactive application with some logic on my server.

Also, if I get something wrong with up_path and finally will get that
working, will that thing work only for Orkut or is it a part of
opensocial standard? If this is only supported in Orkut, I need
something else to implement multiple pages in my application. As far
as I understood, opensocial is an advancement for google gadget
platform, so any gadget functionality will be available in opensocial
containers. How about using javascript "_IG_FetchContent()" function
for loading pages from my server app?

When the People API will be released, will there be a way to
authenticate user which runs the application on my server without
knowing his credentials? I mean if a user has installed my application
and loads it in some opensocial container he uses, will my application
be able to somehow get that user info, based on some session token?

Thank you very much,
Den.

On Nov 20, 11:27 pm, "Arne Roomann-Kurrik (Google)"
<api.kur...@google.com> wrote:
> Hi Den,
>
> Orkut allows for passing data through the querystring to your gadget.
> Any querystring parameters prefixed with "up_" are automatically
> passed to your application, so people have implemented paging through
> links like
>
> http://sandbox.orkut.com/Application.aspx?appId=<your_application_id>&up_path=about
>
> Inside your app, you can check _args()["up_path"] to get the value (in
> this case, it would be "about") and decide which page to show based
> off of this value.
>
> To create a url programatically, you need to get the app ID number.
> There isn't a specific method to get this in the API yet, but you can
> get the App ID by requesting an activitystream for a user:
>
> http://code.google.com/apis/opensocial/docs/javascript/reference/open...

Vanessa

unread,
Nov 29, 2007, 11:37:50 AM11/29/07
to OpenSocial - OpenSocial API Definition
Den,

I did exactly what Arne said and had no problem getting my parameter
value.

Here is my url:
http://sandbox.orkut.com/Application.aspx?appId=5072654245&uid=10859037950336553524&up_scr=canvasEscolhaDeTime&bpc=1

My code
_args()["up_scr"]

value returned "canvasEscolhaDeTime".

Is that what you did?

[]s,
Vanessa.

Luciano Ricardi

unread,
Nov 29, 2007, 12:10:17 PM11/29/07
to opensoc...@googlegroups.com
Den,

We have an application that uses a lot of remote files/content. To do this, we are using a mix of _IG_FetchContent() and remote calls to js files. Unfortunly all the parameters, by now, are passed via GET using _IG_FetchContent(). When you need to pass something like a big text or a file, you have to send it directly to your remote application. For now, this works very well.

Sample code Remote JS:
<script type="text/javascript" src="http://remoteserver/somejs.js">
//code
</script>


Sample code Remote Content:
function f_ViewFiles() {
    var url = 'http://remoteserver/view_content.php?id_orkut=' + id_viewer; // this id_viewer is get from opensocial.
        _IG_FetchContent(url, f_publica_conteudo, { refreshInterval: 5 }); // RefreshInterval is the cache life time (from gadgets API)
        function f_publica_conteudo(conteudo) {
            var div_message = document.getElementById ("message");
                div_message.innerHTML = conteudo;
        }

};

Hope it help you...
--
Luciano

nands

unread,
Dec 1, 2007, 5:56:29 PM12/1/07
to OpenSocial - OpenSocial API Definition
Hi Arne,
Coming back to the implementation of multiple pages of an application
on the canvas, I tried using the tip where one or more arguments could
be passed.
http://sandbox.orkut.com/Application.aspx?appId=<your_application_id>&up_path=about

Now if I make this link as a href , so when clicked the complete orkut
page opens inside my canvas.Basically the full orkut page opens up
inside another...which is not what we want here.

I need a way to browse through the multiple pages of the application
easily.

One way I thought of is that we put the full html code of every page
in seperate div elements in a single file and hide/unhide them or
fetch data to populate them as and when required depending on user
actions through javascript handlers. Ofcouse this works but is there a
better way to do it ?

Thanks.

On Nov 29, 10:10 pm, "Luciano Ricardi" <rica...@gmail.com> wrote:
> Den,
>
> We have an application that uses a lot of remote files/content. To do this,
> we are using a mix of _IG_FetchContent() and remote calls to js files.
> Unfortunly all the parameters, by now, are passed via GET using
> _IG_FetchContent(). When you need to pass something like a big text or a
> file, you have to send it directly to your remote application. For now, this
> works very well.
>
> Sample code Remote JS:
> <script type="text/javascript" src="http://remoteserver/somejs.js">//code
> </script>
>
> Sample code Remote Content:
> function f_ViewFiles() {
> var url = 'http://remoteserver/view_content.php?id_orkut='+ id_viewer;
> // this id_viewer is get from opensocial.
> _IG_FetchContent(url, f_publica_conteudo, { refreshInterval: 5 });
> // RefreshInterval is the cache life time (from gadgets API)
> function f_publica_conteudo(conteudo) {
> var div_message = document.getElementById("message");
> div_message.innerHTML = conteudo;
> }
>
> };
>
> Hope it help you...
>
> On Nov 21, 2007 3:47 AM, Den <golot...@gmail.com> wrote:
>
>
>
>
>
> > Thanks for reply.
>
> > I have several questions again.
>
> > I have tried using up_path parameter, but my application doesn't
> > receive any querystring parameter.
> > My link was:
> >http://sandbox.orkut.com/Application.aspx?uid=17918730883118925891&ap...
Reply all
Reply to author
Forward
0 new messages