How to identify the current opensocial container
December 11, 2007 – 2:44 amWithin my IGCheck gadget (to analyze Google Gadget API compliance for opensocial containers) , I have to identify in which container the gadget code is running.
Currently, I have to differentiate between IGoogle itself, Ning, Orkut & Hi5. They are the only containers that I can access as of now. If you know of more, please let me know!
To distinguish among them, I use the following strategy:
- following this sample, I parse as an associative array the arguments of the url (located at "window.location.search.substring(1)") used to launch the gadget. Then, I get the value of the key 'synd'. It give either: 'ig' (for igoogle), 'hi5' or 'orkut' as of now. So, already 3 out of 4 identified!
- then, for those like Ning that don't run their opensocial APIs with the gmodules infrastructure, I obtain the url argument with key 'location' and look for known string (currently 'ning') to identify the last one.
That's the most "container-orthogonal" way that I found up to now, I you have any better way, let us know!

4 Responses to “How to identify the current opensocial container”
Hi All, dont worry about that. In the near future there will be a support to make it easier.
We will have just to do something like: environment.getDomain() instead of parsing substring like that.
Pato
By Patricio Echague on Dec 18, 2007
Hi again, as i told you here you are how to realize which context the gadget is running on.
http://code.google.com/apis/opensocial/docs/javascript-0.6/reference/opensocial.Environment.html
doing opensocial.getEnvironment().getDomain()
Hope it helps
Pato
By Patricio Echague on Dec 27, 2007
Hi Pato,
Thank you for your details on this new function. I’ll test it right away.
BTW, do you know which containers have opensocial v0.6 already live? (to make use of this new function)
regards
didier
By didier on Dec 28, 2007
Hi, i’m not sure exactly but most of them will be pretty soon. That’s my thought. As you can see at Google Open Social API page, they have published the new API version so i guess it should be implemented soon.
regards
Pato
By Patricio Echague on Jan 3, 2008