Search code examples
facebookdialogsharefeed

Facebook Share Feed Dialog only working for Admins


After creating a Facebook App, leaving it in Sandbox and attempting to setup a Share button using the Feed Dialog, it seems only FB accounts I've added as Admins are able to use the Share button - all other non-Admins are able to see the Feed Dialog popup, but are then seeing "An error occurred, please try again.".

I thought it was a browser specific issue but seems to be dependant on your FB accounts relationship with the App. A person who is a non-Admin has been testing the App and is unable to Share at all.

I am using Wordpress as a CMS backend for this App. As far as I can tell the App ID and App URL are all correct, the only difference is that being on my dev environment it will be moved to a clients production FB page once this is all working.

I find it very bizarre that it works excellent provided you are an Admin of the page. Could it be possible this is simply a Sandbox thing?

I also checked that trying to use the Share button when logged in as a Page as opposed to yourself was the issue, and it is not (if anyone was wondering).

I believe I am using the SDK/API and Feed Dialog correctly, but my code for reference:

header.php

<div id="fb-root"></div>
<script src="https://connect.facebook.net/en_US/all.js"></script>
<script type="text/javascript">
  // Called when FB SDK has been loaded
  window.fbAsyncInit = function () {   
    // Auto resize FB Canvas
    FB.Canvas.setSize({height:600});
    setTimeout("FB.Canvas.setAutoGrow()",500);
  };

  // Load the FB SDK Asynchronously
  (function (d) {
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
    js = d.createElement('script'); js.id = id; js.async = true;
    js.src = "//connect.facebook.net/en_US/all.js";
    d.getElementsByTagName('head')[0].appendChild(js);
  } (document));
</script>

footer.php

<script type="text/javascript">
    FB.init({
        appId: '515010801895800',
        status: true,
        cookie: true,
        xfbml: true
    });

    function postToFeed() {
        var obj = {
            method: 'feed',
            display: 'popup',
            picture: '<?php echo get_template_directory_uri(); ?>/images/app/app-icon-75.png',
            name: 'Suncorp Brighter Futures Heroes',
            caption: '',
            link: 'https://www.facebook.com/aaronlepikdev/app_515010801895800',
            description: 'Suncorp Brighter Futures Heroes is a place where our people come together to share their stories, raise money, volunteer and apply for grants for causes close to their hearts.',
            actions: {name: 'Suncorp Brighter Futures Heroes', link: 'https://www.facebook.com/aaronlepikdev/app_515010801895800'}
        };

        function callback(response) {
            document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
        }

        FB.ui(obj, callback);
    }       
</script>

Any help at all is much appreciated.


Solution

  • It seems I indeed may have answered my own question - I have removed Sandbox and it seems to be working. I did stumble across this though: Sandbox Mode - Please note that when your app is in Sandbox Mode, you cannot call any API calls on behalf of users who cannot see your app.