javascriptfacebookfacebook-javascript-sdkfacebook-sharefb.ui

FB.ui feed or share not returning post_id response


I am trying to use FB.ui share or feed on my test web site and want to get post_id on response message. App has permissions from my test user (user_posts, public_profile) and also i am checking if login status is "connected".

this is javascript code that i am trying to check login and let user to share link. shareOnFacebook() is triggered by a simple html button;

<script async defer src="https://connect.facebook.net/en_US/all.js"></script>


<script type="text/javascript">
    window.fbAsyncInit = function () {
        FB.init({
            appId: '****************',
            cookie: true,                     
            xfbml: true,                    
            version: 'v5.0'         
        });
    };
    function shareOnFacebook() {
        FB.getLoginStatus(function (response1) {
            console.log(response1)
            if (response1.status === 'connected') {
                FB.ui({
                    method: 'feed',
                    link: 'http://www.linktoshare.com',
                    picture: 'http://www.linktoshare.com/images/imagethumbnail.png'
                }, function (responseEnd) {
                    if (responseEnd) {
                        console.log(responseEnd); 
                        alert('Success');

                    } else {
                        alert('Fail');
                    }
                });     
            }
            else {
                FB.login(function (response2) {
                    console.log(response2)
                    FB.ui({
                        method: 'feed',
                        link: 'http://www.linktoshare.com',
                        picture: 'http://www.linktoshare.com/images/imagethumbnail.png'
                    }, function (responseEnd) {
                        if (responseEnd) {
                            console.log(responseEnd);
                            alert('Success');

                        } else {
                            alert('Fail');
                        }
                    })
                });
            }
        });
    }
</script>

As you can see from below image, if i close pop-up, i can get response image like that;

Popup Closed

But when i share, reponse returns as an empty array like that;

Success Post

I know the error about "Https" is not important because my app is on development status.

What should i do to get post_id on response here?

Thank you very much.


Solution

  • What should i do to get post_id on response here?

    You can’t get the post ID any more, Facebook has removed that completely.

    It was getting abused by shady developers and website owners to try and force users to share stuff, to get some kind of reward - which is absolutely not allowed. To stop that kind of spam, Facebook has removed this a while ago already.