Setting Up OpenSocial

I am trying to set up OpenSocial, and I'm finding it rather difficult to get started. I know there is an OpenSocial plugin for Elgg, but the reality is that it won't work. First of all, OpenSocial is up to version 0.9, and Shindig itself has changed as well. In addition, the new requirements are a bit higher for PHP

So, in order for the Elgg community to benefit, I thought it would be useful to create a discussion to show ourselves how to set up OpenSocial for any Elgg site. Here is what I am doing to set it up.

1) Go to Shindig website and download the package: http://incubator.apache.org/shindig/.

2) Unzip it and get the shindig folder inside, just as you would do an Elgg plugin. Rename it to shindig and upload it to your html root (i.e. right after your domain name).

3) From here, it's not too clear what you have to do. There are two options:

a. Create a new virtual host

Point your Apache to the shindig dir with a virtual host like: <VirtualHost your_ip:your_port> ServerName your.host DocumentRoot /var/www/html/shindig ... other normal settings in vhosts... <Directory> AllowOverride All </Directory> </VirtualHost> Restart apache, and point your browser to: http://<your.host>/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml b. Run with an existing host If you cannot/don't want to create a virtual host, you can edit the file php/config/container.php or php/config/local.php (see the comments php/config/container.php for documentation of the configuration system) and change the web_prefix setting to '/shindig/php'. In this case, you should also change all paths in shindig/config/container.js (see the comments there for documentation of the JSON configuration system). Then you can run the gadget by pointing your browser to: http://<your.host>/shindig/php/gadgets/ifr?url=http://www.labpixies.com/campaigns/todo/todo.xml ------------------------------------------------------------------------------------ Ok, so here is why this is confusing. They say that if you don't want to create a virtual host, which I assume for most people will be quite difficult, then you need to change the file found at php/config/container.php. The problem is that there isn't a folder called php/ in the first place. There is the one that you rename, shindig, that contains config/container.php and there you can change the web_prefix, but when you do that and then change all the paths in shindig/config/container.js (notice the "shindig/" now), it still doesn't work. So that's where I'm at right now. Here are some resources for using available apps once you set up OpenSocial correctly: http://www.opensocial.org/ http://www.joyent.us/developers/opensocial/ http://directory.opensocial.org/gadgets/directory?synd=cad&cat=all http://opensocialapps.com/ http://gadgets.zoho.com/zc/index.do Would appreciate for people to join the discussion and help make using OpenSocial clearer for everybody.

  • A few more comments on setting up Shindig. Here is another problem. Let's say you manage to do either step 1 or two. Now, you should be ready to render a gadget and see it in action, so you go to http://yourhost.com/ or http://yourhost.com/shindig/php/gadgets/ifr?url=URLtoGadgetSpec. The problem is, when you go there, there is nothing because gadgets is not right after /php. 

    I took option B to see if this would work, but it's not working. There is a "gadgets" folder right below shindig/php/src, but it doesn't contain an ifr.php file of any sort. I also tried doing this as http://myhost.com/shindig/php/src/gadgets/ifr...., but that didn't work either.

    Any ideas?

  • Ok, I made some progress. I figured out what all of this is doing. Basically, when you say yourhost.com/shindig/php/gadgets/ifr?url=GADGETURL, you are calling on files already inside the shindig folder without knowing it. It's similar to how in Elgg you can set pg/profile to call to the directory mod/profile/index.php.

    So, here is what YOU MUST KNOW to get it working, kind of. If you choose Option B (probably recommended and easier), you must go to shindig/php/config/container.js, shindig/php/config/container.php, and shindig/php/.htaccess to change the directories. You must add /shindig/php/ to every single directory you see. That should fix things.

    Now, I did that, but I tried rendering the ToDo app and it didn't work. Something DOES show up, but an error message appears that says the following:

    Unknown features: setprefs,opensocial-0.8,analytics,dynamic-height,views Debug backtrace... followed by long code...

     

    I don't know why this error is coming up, but I'll come back if I figure out what to do from here.

  • SOLVED

    I found why the error above was showing up. When you go to /shindig/php/config/container.php, only change the directory for the first three. So, you'll be changing these:

    web_prefix: from '/' to '/shindig/php'

    default_js_prefix: from '/gadgets/js/' to '/shindig/php/gadgets/js/'

     default_iframe_prefix: from '/gadgets/ifr?' to '/shindig/php/gadgets/ifr?'

    That's it! Don't change anything else in this file. You still MUST change .htaccess and container.js to reflect the fact that now everything is under yourdomain.com/shindig/php/. Once you do all of this, you'll be set. Simply go to http://yourdomain.com/shindig/php/gadgets/ifr?=url=http://www.labpixies.com/campaigns/todo/todo.xml to see a gadget in full action!

    From here, you have to know a bit of the Elgg code to start creating gadgets or using existing ones from the resources I provided above.

    Enjoy!

    Carlos

  • Thanks Dhrup. I had seen that discussion, but for the beginner to go and follow the not-so-clear instructions in the new version of Shindig/OpenSocial, it's a bit hard to understand what to do. But this just adds to the clarification, so anything else that should be shared, please do so here and hopefully this can serve as a resource for people.

    Thanks!

    Carlos

  • There was another more detailed discusion abt Dec 2008 @ Google where more code was discussed, I just don't remember.. so long ago.. but I do remember helping someone along to get their code going - then they disappeared without sharing their own working code. I've probably got my own first working tests *somewhere so far away that I cannot relocate it..

    Just remember - Elgg only ptovides the "container" - you (admin) need to supply the open social actual code - so you better know a little techie abt how code is encapsulated in open social.

    If I find my original OpenSocial working test code from Dec 2008.. we'll all be lucky ;-)

  • That's true. Once you build a container you still have to figure out a few other things. However, there are some good instructions at www.opensocial.org on how to get gadgets working. Builiding a gadget is a lot harder, but there are a ton out there available, and all you'd need to do is link them to Elgg to get data and such.

    I'm working on that right now to see how I can make use of some of the apps listed in the resources above. Dhrup, if you could find your code from 08 that could help us get apps working with a container, that would be wonderful.

    Also, just as a note, the container offered in that OpenSocial plugin wasn't built right into Elgg. Having said that, it shouldn't be hard to build it right into your Elgg template. You just need to add your css, header, header_content, elgg_topbar, and footer. From there it depends where you want to show the particular app. 

    Code for linking apps to user IDs, friend IDs, activities, river, etc. would be very useful. :)

  • Do we have a few more details on how to preceed after Shindig is installed and ready for use?
    I know the options and features are endless, but I think this is where the newbies (like myself) get lost trying to create widgets with OpenSocial.  Perhaps a Plugin that creates just the container??

  • Once Shindig is set up, you should be able to display any app that has an .xml source and all the javascript/css included in it. Some apps require you to actually put in additional information from the Elgg system, such as for displaying friends, making relationships, streaming activity on the river, etc.

    Once you set up Shindig, for example, you can display an App by going to http://www.yourdomain.com/shindig/php/gadgets/ifr?=[The XML URL] or simply http://www.yourdomain.com/gadgets/ifr?=[The XML URL] (if your domain name is your shindig server). 

    If you want to do something more creative, go to this site: http://gae-opensocial.appspot.com/index.html and copy coding from the source (go to View Source on your browser). There, you'll be able to copy code so that you just click on a link and an app shows inside any <div> you create. 

    As for a plugin that creates a shindig container, there is one available on Elgg (just search for it), but I just don't prefer doing it that way because it's a bit confusing. I instead created a shindig server on my root server directly.

    Hope this helps.

rym87

Experienced Elgg developer with track record of doing almost anything with Elgg. I am also very willing to answer any questions regarding Elgg to people working on exciting projects.