Search code examples
facebookangularjsfacebook-javascript-sdkfacebook-commentsangularjs-service

ng facebook with facebook comments


I am using ng-Facebook service in my angular web app. I want to include a Facebook comments plugin. So, I have copied the code in the Facebook plugin with the Javascript SDK. I can see the comments in my page but the ng-Facebook service is not working.

I am getting this error:

FB.init has already been called - this could indicate a problem sdk.js:54
Uncaught Error: invalid version specified  sdk.js:85

The code is in a plunkerlink

How is the service not working but I can still see the comments?


Solution

  • I don't know did you solved your issue but facebook changed their javascript-sdk code. I got same error with you and my javascript code was like this;

    <div id="fb-root"></div>
    <script type="text/javascript">
     window.fbAsyncInit = function () {
        FB.init({
            appId: 'xxxxxxxxxxx',
            status: true,  
            cookie: true,  
            oauth: true,  
            xfbml: true
        });
    };
    (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/tr_TR/sdk.js#xfbml=1&version=v2.1";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    

    And I changed it like this. Then error gone.

    <div id="fb-root"></div>
    <script>
    (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/tr_TR/sdk.js#xfbml=1&appId=xxxxxxxxxxxx&version=v2.0";
        fjs.parentNode.insertBefore(js, fjs);
     }(document, 'script', 'facebook-jssdk'));</script>
    

    Hope this will help