skip to Main Content

I am working on share functionality using Facebook. The login functionality is working fine. But when I try to share something using a sample code, it is showing like

Sorry, something went wrong.

We’re working on getting this fixed as soon as we can.

The code I am using is

$('#fb_test').on('click', function(e){
    e.preventDefault();
    FB.ui(
    {
        method: 'feed',
        name: 'This is the content of the "name" field.',
        link: 'URL which you would like to share ',
        picture: "URL of the image which is going to appear as thumbnail image in share dialogbox",
        caption: 'Caption like which appear as title of the dialog box',
        description: 'Small description of the post',
        message: ''
    }
    );
});

2

Answers


  1. Use this code instead of yours this will works fine.

    First reference this fb script after the body tag

    <script>
        window.fbAsyncInit = function() {
            FB.init({
                appId      : 'app_id',
                xfbml      : true,
                version    : 'v2.8'
            });
            FB.AppEvents.logPageView();
        };
    
        (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 call this method on your <a> click:

    function ShareOnFacebook(){
    FB.ui(
    {
    method: 'feed',
    name: 'test Blog title',
    link: 'http://stackoverflow.com/',
    picture: 'https://pbs.twimg.com/profile_images/740344950097903616/mORHo2rZ.jpg',
    caption: 'I love stackoverflow',
    description: 'The stackoverflow forum will provide good solutions',
    message: ''
    });
    }
    

    This will work for you 🙂

    Login or Signup to reply.
  2. It seems like this error can happen for any number of reasons, and they don’t tell you what the problem is.

    In my case, I omitted the # from the hashtag field, which is apparently cause for total failure.

    win.FB.ui({
      method: 'share',
      href,
      hashtag: '#wow', // NOT 'wow'
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search