FB.ui share_open_graph奇怪的对话行为

时间:2017-09-30 21:42:00

标签: facebook facebook-graph-api facebook-javascript-sdk

我需要通过javascript在Facebook上实现网址共享,并分享图片。 当FB共享对话框出现时,它开始缩小,并且越来越多地缩小,直到它变成大约20像素宽。

它使用share_open_graph或“share”方法发生。

此外,在JS控制台上,当出现共享对话框时,我看到此错误:

ErrorUtils caught an error: "<![EX[["Could not find element \"%s\"%s 
from module \"%s\"","u_0_18","","__el...". 
Subsequent errors won't be logged; see https://fburl.com/debugjs.

这是我的代码:

<script>
    $(document).ready(function() {
        $.ajaxSetup({ cache: true });
        $.getScript('//connect.facebook.net/en_US/sdk.js', function(){
            FB.init({
                appId: '476337039102253',
                version: 'v2.8'
            });
            FB.getLoginStatus(APP.fbUpdateStatusCallback);

        });            
});
</script>

<button id="itb" class="btn btn-primary btn-large active_down" name="btn" onclick="
            FB.ui({
                method: 'share_open_graph',
                action_type: 'og.shares',
                action_properties: JSON.stringify({
                    object: {
                        'og:url': 'https://example.com',
                        'og:title': 'page title',
                        'og:description': 'desc',
                        'og:image': 'https://savebybooking.s3.amazonaws.com/public/prd/File_341'
                    }
                })             
            }, function(response){
                if (response &amp;&amp; !response.error_message) {
                  console.log('fb sharing OK: '+JSON.stringify(response));
                } else {
                 console.log('Not OK: '+JSON.stringify(response));
                }
           }); return false;" type="submit">Share</button>

你有同样的问题吗?为什么会这样? 我使用“共享”方法直到昨天没有问题,今天出现了这个问题而没有修改我的代码。

P.S。我更喜欢     使用share_open_graph 而不是     分享 方法,因为后者不会让你分享指定的图片,但似乎从你正在分享的网址中选择一个随机图片。

1 个答案:

答案 0 :(得分:0)

这是FB对话框内的错误,而不是启动对话框的页面内的错误。也是因为您在共享页面上缺少元标记。 FB没什么要抢的。