Tiberiu Popescu
Tiberiu Popescu

Reputation: 4524

Facebook js-sdk share button from localhost

I'm trying to create a share button with facebook javascript SDK :

I have added this code to my page

    window.fbAsyncInit = function() {
    FB.init({
      appId      : 'my app id xxxxxxxxxxxxx',
      xfbml      : true,
      version    : 'v2.6'
    });
  };

  (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/en_US/sdk.js";
     fjs.parentNode.insertBefore(js, fjs);
   }(document, 'script', 'facebook-jssdk'));

    $('.btnShare').click(function () {
        FB.ui({
            method: 'feed',
            link: "http://localhost:5000/",
            picture: 'http://localhost:5000/src/assets/image.JPG',
            name: "The name who will be displayed on the post",
            description: "The description who will be displayed"
        }, function (response) {
            console.log(response);
        });
    });

I click on the share button and an iframe opens and it throws this error:

Can't Load URL: The domain of this URL isn't included in the app's domains. To be able to load this URL, add all domains and subdomains of your app to the App Domains field in your app settings.

Any ideas ?

Upvotes: 2

Views: 2736

Answers (1)

Andreas Gnyp
Andreas Gnyp

Reputation: 1840

As described here, you will probably need to tweak your settings in facebook a bit.

Upvotes: 1

Related Questions