+ Start a Discussion
Chirag MehtaChirag Mehta 

Salesforce to Facebook: How to call and connect to Facebook from Apex

Facebook toolkit was published for Salesforce.  Using that toolkit its possible to connect Facebook right inside from Salesforce.  I am trying to make a Apex to Facebook API call to fetch in groups related to my facebook id using following snippet

FacebookSession fbsession= new FacebookSession(appKey,appSecret,'','');
List<IFacebookQueryResult> groups = fbsession.query('Select name, venue, gid FROM group WHERE gid IN (SELECT gid FROM group_member WHERE uid = \'11111111111\')');

It throws following error
<error_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <error_code>102</error_code> <error_msg>Session key invalid or no longer valid: </error_msg> <request_args list="true">

To my knowledge before instantiating FacebookSession Class,I need to fetch session id and set it as 4th parameter of FacebookSession constructor.Can someone guide me how to fetch session id or is there anything else i am missing .

Samples or Examples depicting salesforce-facebook connection will be really appreciated!

This link provides a walkthrough on Using the Force Toolkit for Facebook



Chirag MehtaChirag Mehta

@aalbert - Thanks !


Obviously the article pointed by you is the first step of using facebook toolkit. I installed and navigated to FBToolkitPage, it doesnt work. It comes out with a blank page.


Fyi, the same error have already been posted by many of the developers on the community. Following are few of the references



Also see a note from the developer of facebook toolkit stating about this issue



So can anyone help me to connect.... successfully connect .... to Facebook from Apex. 



Hi all,


Has any one managed to successfully connect to Face book. I am getting a blank page when I used the very first version that they put up on google code.


The documentation is a mess. They do not maintain version specific docs out there.





i managed to connect facebook.It depends on your facebook apps configuraiton.Add force.com url to ur facebook app.

buchi Boggavarapubuchi Boggavarapu
can anyone give code for salesforce to facebook integration code.