fb.init fb未定义

时间:2019-07-15 22:14:36

标签: javascript facebook-graph-api facebook-javascript-sdk

我有一个简单的视频,其中最后包含一个共享按钮,当用户单击一个共享按钮时,一个Modal会打开并带有社交媒体图标,例如,用户可以将视频共享给Facebook,现在我需要Facebook的回调响应分享视频后。

这是我到目前为止尝试过的。

FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});

FB.ui({
    method: 'feed',  
    link: "http://...",
    name: "Some Title",
    caption: "Some Caption",
    description: "Some Description",
    display: "popup",
    Video: "http://..."
}, function(response) {
    if (response && response.post_id) {
        alert('Post was published.');
    } else {
        alert('Post was not published.');
    }
});

不幸的是出现以下错误

fb.init fb is not defined

我在做什么错???

1 个答案:

答案 0 :(得分:1)

我猜您不是要导入正在使用的实际库。我建议您在这里看看如何做:https://developers.facebook.com/docs/javascript/quickstart

我还注意到您以大写(FB.init...)列出代码,而错误以小写(fb.init...)列出。确保使用与导入相同的外壳。

相关问题