The Dead Man
The Dead Man

Reputation: 5566

fb.init fb is not defined

I have a simple video in which at the end it contains a share button , when user clicks a share button a Modal opens with social media icons, eg user can share the video to Facebook, now I want a callback response from Facebook after the video was shared.

Here is what I have tried so far.

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.');
    }
});

Unfortunately am getting the following errors

fb.init fb is not defined

What am I doing wrong???

Upvotes: 0

Views: 296

Answers (1)

Freddy
Freddy

Reputation: 1229

I would guess that you're not importing the actual library that you are using. I would recommend taking a look how to do that here: https://developers.facebook.com/docs/javascript/quickstart

I also notice that you are listing code in upper-case (FB.init...) whereas your error is coming in in lower-case (fb.init...). Make sure that you are using the same casing as how you are importing it.

Upvotes: 1

Related Questions