And Finally
And Finally

Reputation: 5714

Facebook Feed Dialog using FB.ui gives API error 191

I want to add a custom Facebook share button to my website like the ones you see at the top of BBC news stories, like http://www.bbc.co.uk/news/uk-19535236. They're using the Facebook Feed Dialog for this. So when you click on the link you get a dialog that allows you to post the URL of whatever page you're on to your timeline.

The FB.ui method seems the best way of invoking the dialog, because it automatically creates the right type of popup for your device. So people using mobiles'll see a popup that suits their devices. This method also allows us to specify a callback, so once the user's shared a link we can augment the share count on the page they're sharing.

I'm trying to follow the first example on http://developers.facebook.com/docs/reference/dialogs/feed/.

<div id='fb-root'></div>

<script src='http://connect.facebook.net/en_US/all.js'></script>

<p><a href="#" onclick='postToFeed(); return false;'>Post to Feed</a></p>

<p id='msg'></p>

<script>
    FB.init({appId: "00000000000", status: true, cookie: true});

    function postToFeed() {

        // calling the API ...
        var obj = {
            method: 'feed',
            link: 'http://example.com/',
            picture: 'http://fbrell.com/f8.jpg',
            name: 'Facebook Dialogs',
            caption: 'Reference Documentation',
            description: 'Using Dialogs to interact with users.'
        };

        function callback(response) {
            document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
            if (response && response.post_id) {
                alert('Post was published.');
            } else {
                alert('Post was not published.');
            }
        }

        FB.ui(obj, callback);

    }

</script>

(subsituting my actual app_id for 00000000000 and site URL for http://example.com/). But I get this error when I click on the link:

API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: redirect_uri is not owned by the application.

I get this even when the 'link' parameter exactly matches the 'Site URL' for the app in my Facebook app settings.

Can anyone tell me how I can get this to work? I want people to be able to share any page on my site, not just a URL corresponding to my Facebook app.

Upvotes: 2

Views: 2813

Answers (1)

Abhishek
Abhishek

Reputation: 836

For sharing to work, minimum requirement in application configuration is to set atleast

App Domains ( under Basic Info )

Site URL ( under Website with Facebook Login )

i.e.

App Domains : example.com
Site URL : http://example.com

setting other parameters can also work like Mobile Site URL etc.

Upvotes: 3

Related Questions