+ Start a Discussion
jpizzalajpizzala 

Facebook connection issue - "api_key is not set"

I have created an app in Facebook to test out the new integration with Force.com via Visualforce.  However, whenever I try to execute a page with the FacebookConnection controller class, I get an error message saying "api_key is not set".  I followed the tutorial on the wiki, which I assume is the most recent, up-to-date version.  I have put the FB API Key and FB Secret values into a FacebookAppList__c record as demonstrated in the tutorial.

I also noticed that there is another object included in the Facebook package called FacebookApp__c.  Is this a deprecated object?  I notice that there are still multiple occurances of this in the existing Apex classes included with the package.  What is this for?  Do I need to create a FacebookApp__c record as well as the FacebookAppList__c record?  They both hold very similar information yet both are present in the existing Apex classes - including the FacebookConnection class.
dchasmandchasman
I have emailed the FB toolkit author to let him know about your problem - stay tuned.
jpizzalajpizzala
Thanks, Doug!
DevAngelDevAngel
If you are trying to view the test page on the Force.com platform, you should put the name of the record that you created in FacebookAppList on the url, like https://na1.salesforce.com/apex/testpage?appName=MyApp

I may have neglected to mention that in the tutorial.  What happens is when the page loads the FacebookConnection initialization method attempts to locate the Facebook api key in the database.  In the case of an app running on the Force.com platform, it does this using the Name of the FacebookAppList record that you created.  In the case of an app running on Facebook, it does this using the api key passed to the page by the Facebook platform.

Once the record is located, it uses the Facebook API key and the Facebook app secret to initialize the Connect pieces and is also used for Facebook web service api.

The FacebookApp record, on the other hand, is used to record visitors to your app.  Once the app has been authorized, the Facebook user id and session key are recorded for the app that was authorized.  Any facebook user should end up with one record per app that you host.  The session key is transient, in other words, any time facebook includes a session key when your page is requested, the session key is replaced with the current one from facebook.

There may be a bit of, um, "non essential" code in the toolkit.  In the coming days and weeks I am keen to clean it up properly.


Cheers
jpizzalajpizzala
Many thanks!  I was wondering how the page knew which API key to use...
Saurabh_RawaneSaurabh_Rawane

Hi Dev,

 

I am trying work on things posted on this URL 'http://wiki.developerforce.com/index.php/Using_the_Force_Toolkit_for_Facebook', initially i also faced the same issue, related to api_key not set, which then i corrected with your suggested solution, 'https://meondemand.na5.visual.force.com/apex/FBToolkitPage?appName=FBTest' but no luck instead of getting an alert message now i get is a blank screen.

 

Please let me know how can i go about it.

 

Thanks,

Saurabh

Chirag MehtaChirag Mehta

Dev,

 

I am trying to make a pretty small call Apex-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 .