尝试呼叫时:
FB.api(`/${authResponse.userID}/adaccounts`, accountsResponse => {
console.log('accountsResponse ', accountsResponse);
});
根据文档的here,我们得到以下响应:
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"
问题是,我们使用的是v8.0版本,与这个错误消息中包含的信息相反,它是最新版本!
下面是我们如何加载SDK (使用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,
}
所以这有点奇怪,但我们根本不能让建议的"sdk.js“工作,至少这会加载并允许我们成功地调用FB.login()。
下面是我们初始化的方法:
FB.init({
appId,
autoLogAppEvents: true,
xfbml: true,
version: 'v8.0',
});
将此版本号更改为'v7.0‘不起作用。
发布于 2020-09-02 04:47:33
因此,似乎在head()中加载sdk.js,而不是使用标记,在某种程度上把所有人都搞糊涂了。由于让Vue不高兴,我们不得不找到另一个解决方法,我们做到了,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);
}
https://stackoverflow.com/questions/63688791
复制相似问题