在og的白色空间:Facebook分享中的图像

时间:2017-11-07 14:12:36

标签: facebook-opengraph fbsdksharedialog

我创建了一个share_facebook函数。当用户点击该按钮时,它将提示他们登录Facebook并共享我们的网站。但是,在共享对话框中,右侧有一个无法消除的空白区域。我正在使用Facebook推荐的图像尺寸1200x630px。这里有人可以帮忙吗?

screen shot of the facebook share dialog

    (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'));

      window.fbAsyncInit = function () {
        var appId = '1746827655661251';
        FB.init({
          appId: appId,
          xfbml: true,
          version: 'v2.9'
        });
      };

      function share_facebook()
      {
        event.preventDefault();
        event.stopPropagation();
        event.stopImmediatePropagation();

        // Dynamically gather and set the FB share data. 
        var FBDesc      = 'Water and Sump Pump Backup is an endorsement to the Homeowners Policy that is often forgot about by first time home buyers. A homeowners insurance policy in its standard form will not cover water that is “backed up” through a drain, toilet, etc';
        var FBTitle     = 'Welcome to my site';
        var FBLink      = 'https://www.mygreatsite.com/';
        var FBPic       = 'https://www.mygreatsite.com/images/home_feature2.jpg';

        // Open FB share popup d
        FB.ui({
            method: 'share_open_graph',
            action_type: 'og.shares',
            action_properties: JSON.stringify({
                object: {
                    'og:url': FBLink,
                    'og:title': FBTitle,
                    'og:description': FBDesc,
                    'og:image': FBPic
                }
            })
        },
        function(response)
        {
          //response codes
        });
       }

1 个答案:

答案 0 :(得分:0)

找到解决方案 - 我使用'share'而不是使用'share_open_graph'方法。