user736893
user736893

Reputation:

Facebook API "invalid version specified"

The Facebook API login "quickstart" page says to put the following code in your page:

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '{your-app-id}',
            cookie     : true,
            xfbml      : true,
            version    : '{latest-api-version}'
        });
        FB.AppEvents.logPageView();
    };

    (function(d, s, id){
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/en_US/sdk.js";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
</script>

App ID is easy, but what on earth is it expecting for {latest-api-version}? I've tried both '2.1' and '2' and both values throw "invalid version specified" to the console.

Upvotes: 6

Views: 5220

Answers (2)

user736893
user736893

Reputation:

The trick is including v in the version. Some users may also have neglected to remove the {brackets}.

As of 2021-06-08 the code should look like this:

        version : 'v11.0'

Readers from the future (or the past) can view this table for different versions: https://developers.facebook.com/docs/graph-api/changelog/versions

Upvotes: 14

Atahala
Atahala

Reputation: 19

use: "v5.0" NOT "{v5.0}"

eg:

    FB.init({
        appId      : 'xxxxxxxx',
        cookie     : true,
        xfbml      : true,
        version    : 'v5.0'
    });

Upvotes: 1

Related Questions