0

So today, I created a test app in Facebook. I followed the wizard. It told me to add this code right after . I see sdk.js in my console, it gets loaded fine.

<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : '1xxxxxxxxxxxxxxx',
            xfbml      : true,
            version    : 'v2.2'
        });
    };

    (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'));
</script>

Then it also told me to add this code somewhere in the body.

<div class="fb-like" data-share="true" data-width="450" data-show-faces="true"></div>

However, I'm getting this error

Uncaught SecurityError: Blocked a frame with origin "https://s-static.ak.facebook.com" from accessing a frame with origin http://www.ourdomain.com. Protocols, domains, and ports must match.

I've followed other solutions I found earlier on this site but none of them helped.

devwannabe
  • 3,160
  • 8
  • 42
  • 79
  • possible duplicate: http://stackoverflow.com/questions/14892556/facebook-unsafe-javascript-issue-document-domain-values-should-be-same – Ronnie Mar 09 '15 at 22:19
  • That's the instructions I followed which didn't help. – devwannabe Mar 09 '15 at 22:22
  • That widgets uses SSL (**https**) and your domain is on standard **http**, hence the problem. Maybe they provide a http widget? otherwise you need to switch yours – floribon Mar 09 '15 at 22:26
  • did you try the `htaccess` solution? – Ronnie Mar 09 '15 at 22:34
  • Yes, I have that too and even restart apache services. The suggestion there is actually for CORS - https://gist.github.com/c0debreaker/808d84a888bb230fe773 – devwannabe Mar 09 '15 at 22:39
  • @floribon check this out using https - http://i.imgur.com/uquAPcd.png – devwannabe Mar 09 '15 at 22:43
  • I got it working even if there is still that error in Console. I'm not sure how it's related but I added FB.getLoginStatus(function(response) { .... } then refreshed my browser. Chrome blocked a popup but I allowed the domain. I refreshed my browser and I saw Facebook window. I clicked Allow and it went back to my page as if nothing happened. Now I logged in to my page and saw the Like button. I clicked Like and it updated my Activity log in Facebook :) – devwannabe Mar 09 '15 at 23:00

0 Answers0