Marc
Marc

Reputation: 1902

Facebook: "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v7.0."

When attempting to call:

        FB.api(`/${authResponse.userID}/adaccounts`, accountsResponse => {
            console.log('accountsResponse ', accountsResponse);
        });

as per the docs here, we get this response:

error:
code: 2635
fbtrace_id: "AtKWTpvIoYCi5YXpg-2Xr0g"
message: "(#2635) You are calling a deprecated version of the Ads API. Please update to the latest version: v7.0."
type: "OAuthException"

The trouble is, we are using version v8.0, which is, contrary to the information contained in this erroneous error message, the latest version!

Here is how we load the SDK (using Nuxt):

        {
            // replaced "sdk.js" with "all.js" due to "init not called with valid version"
            // problem solved... but apparently this is bad
            // see https://gist.github.com/tpai/602898fe0d3d630f0099d58856cef352
            // other proposed solutions fail.
            src: 'https://connect.facebook.net/en_US/all.js',
            crossorigin: 'anonymous',
            async: true,
            defer: true,
        }

So this is a bit strange, but we can't get the suggested "sdk.js" to work at all, and at least this loads and allows us to call FB.login() successfully.

and here is how we init:

                        FB.init({
                            appId,
                            autoLogAppEvents: true,
                            xfbml: true,
                            version: 'v8.0',
                        });

Changing this version number to 'v7.0' has no effect.

Upvotes: 0

Views: 1741

Answers (1)

Marc
Marc

Reputation: 1902

So, it seems that loading sdk.js in head(), rather than using a tag, confuses everyone somehow. Since makes Vue unhappy, we had to find another workaround, which we did, right here:

mounted() {
        const fbDiv = document.createElement('div');
        fbDiv.id = 'fb-root';
        document.body.appendChild(fbDiv);
        // run after sdk is loaded
        window.fbAsyncInit = () => {
            FB.init({
                appId,
                autoLogAppEvents: true,
                xfbml: true,
                version: 'v8.0',
            });
        };
        // inject sdk.js
        (function (d, script) {
            script = d.createElement('script');
            script.type = 'text/javascript';
            script.async = true;
            script.src = `https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v8.0&appId=${fbAppId}&autoLogAppEvents=1`;
            d.getElementsByTagName('head')[0].appendChild(script);
        })(document);
    }

Upvotes: 1

Related Questions