Search code examples
javascriptfacebookfacebook-javascript-sdkfacebook-sharerfacebook-share

Given The domain of this URL isn't included in the app's domains...: Facebook Dialogs (FB UI)


I am following the steps to implement Facebook UI Dialogs

My idea is to implement custom actions at the moment when user share a post from my website.

I have been created my app, i have placed my app url, my app domain (same to app url), and i have placed all necessary code in my site, and when i pressed button share, it throws:

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

This is my code:

<script type="text/javascript">
    $(function(){
        // initialize fb sdk
        window.fbAsyncInit = function() {
            FB.init({
              appId      : 'appid',
              xfbml      : true,
              version    : 'v2.8'
            });
        };

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

    function share_property(){
        FB.ui({
          method: 'feed',
          link: 'link',
        }, function(response){});
    }
</script>

and the html to the button:

<div class="query-submit-button pull-right">
    <input id="shareBtn" type="button" value="Compartir" onclick="share_property();">
</div>

Solution

  • You don´t need to track shares for statistics on your own, there are analytics for Apps: https://www.facebook.com/analytics/[app-id]

    There is a specific page for Sharing stats: https://www.facebook.com/analytics/[app-id]/?section=link_sharing

    Either way, you need to include the Domain of your App in the App settings, as the error message tells you.