Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 1000
THE JOATMON Avatar asked Sep 21 '17 15:09

THE JOATMON


1 Answers

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

like image 129
THE JOATMON Avatar answered Nov 18 '22 07:11

THE JOATMON