I have just managed to do a server-side integration of Google Friend Connect on raya. It took awhile to do this mainly because I realised that the deserialization mechanism has not been implemented properly. So in the end I did a quick custom javascript deserializer for JSON objects in pesta.
Information on how to support Google Friend Connect can be found here. Basically, there are three ways you can go about adding Google Friend Connect support to your site
- Copy and paste generated javascript code on to your web pages. This is similar to the method for inserting Google AdSense into your web pages.
- Using GFC's Javascript API. This is a bunch of javascript functions you can call to communicate with the GFC server.
- Making calls to the RESTful endpoints for GFC using the OpenSocial API server-side, i.e instead of the client's browser making the calls. The call will originate from your site.
For more details, you can read the GFC quick start guide. Basically, I used the javascript API for logging in the user to obtain the authentication cookie. Once that is done, this cookie is checked for on the server. Using this cookie, user information is obtained from the RESTful endpoint of GFC.
No GFC login pop up
There was one thing that tripped me up for awhile. Initially, clicking on the GFC Sign In button will pop up a login page. However, while testing it locally the button did not pop up. You actually need to specify an alternate address for your GFC site from your GFC admin site. This can be found under Site Settings -> Advanced -> Other Options -> Alternate Addresses. Here you can specify your localhost address, e.g. http://localhost:8080.
Different FCAuth Cookie name
The other issue was that while testing it locally the name of the authentication cookie is slightly different. Normally, the format of the authentication cookie is of the form
"fcauth" + YOUR_GFC_SITE_ID
However, locally, it's actually
"fcauth" + YOUR_GFC_SITE_ID + "-s"
-s for secondary??
The utility class that was created for handling Google Friend Connect can be viewed here and has an example of obtaining user data from the RESTful endpoints of Good Friend Connect. Or if you prefer the entire application. Go to the raya project page. In the future, hopefully I will have time to integrate other GFC features.