Jim Miller
Jim Miller

Reputation: 3329

How do you get the Facebook apiKey from the Javascript API?

It used to be the case that you could test for the presence of a valid api key in the Javascript API by checking FB._apiKey. However, it looks like that has gone away in the latest deprecations to the API (https://developers.facebook.com/blog/post/2012/05/16/platform-updates--operation-developer-love/):

In the upcoming weeks, we will be updating the Javascript SDK to limit the publicly exposed interface. This is part of an ongoing process to improve the reliability of the SDK. The first step will include removing access to all internal properties and to methods prefixed with _.

So: Is there another way to get at what was previously available via FB._apiKey?

Upvotes: 0

Views: 286

Answers (1)

You typically initialize FB.init with your appId (aka API Key)

You can always store that as a separate variable and reference it, like so:

window.fbKey = 'YOUR_APP_ID';
window.fbAsyncInit = function() {
    FB.init({
      appId      : fbKey, // App ID
      channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
      status     : true, // check login status
      cookie     : true, // enable cookies to allow the server to access the session
      xfbml      : true  // parse XFBML
    });

Upvotes: 1

Related Questions