facebookfacebook-javascript-sdkfacebook-wallfb.ui

Share link to posts when using FB.ui


I made a small app to FB that is using FB.ui to allow users to share it on their wall. I'd like the shared posts to show "Share" link next to "Comment" and "Like", like on any normal wall post.

Is there any way to do this with FB.ui?

Or is there some other method that would still allow me to define customized image, title, description etc. to the wall post?

My current code:

function share(name, description) {
        FB.ui({
            method: 'feed',
            name: name,
            picture: '/img/fb.png',
            link: url,
            caption: '',
            message: '',
            description: description
            }, function() {
            });
    }

Solution

  • it can be done with share_open_graph method. the code should look like this

    FB.ui({
        method: 'share_open_graph',
        action_type: 'og.shares',
        action_properties: JSON.stringify({
            object : {
               'og:url': 'http://astahdziq.in/', // your url to share
               'og:title': 'Here my custom title',
               'og:description': 'here custom description',
               'og:image': 'http://example.com/link/to/your/image.jpg'
            }
        })
        },
        // callback
        function(response) {
        if (response && !response.error_message) {
            // then get post content
            alert('successfully posted. Status id : '+response.post_id);
        } else {
            alert('Something went error.');
        }
    });