本文介绍了Facebook的Feed对话框中的“图片"已弃用,我该如何发布图片链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Facebook的Feed对话框,让网站上的用户共享其Facebook feed上的内容.在他们的供稿上,将有一张图片,链接到我网站上的页面,下面有一些文字(名称,标题和描述字段).所有这些图片,名称,标题和描述现已弃用,并于7月17日停止工作.还有其他方法可以使用其他方法来实现此功能吗?

I've been using Facebook's Feed Dialog to let users on a site share content on their Facebook feed. On their feed there would be a picture that serves as a link to the page on my site, with some text below it (name, caption and description fields). All of these - picture, name, caption and description are now deprecated and stop working on July 17th. Is there any other way to achieve this functionality using a different method?

推荐答案

您需要使用本页底部所述的打开图"操作方法在FB开发文档中.

You need to use the Open Graph actions method described at the bottom of this page here in the FB dev docs.

在代码中尝试此操作,以在FB共享上指定自定义图像,标题,描述或链接:

Try this within your code to specify a custom image, title, description or link on your FB shares:

    // this loads the Facebook API
    (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 = '1937011929814387';
        FB.init({
            appId: appId,
            xfbml: true,
            version: 'v2.9'
        });
    };

    // FB Share with custom OG data.
    (function($) {

        $('.fb_share_btn').on('click', function (event) {
            event.preventDefault();
            event.stopImmediatePropagation();

                // Dynamically gather and set the FB share data.
                var FBDesc      = 'Your custom description';
                var FBTitle     = 'Your custom title';
                var FBLink      = 'http://example.com/your-page-link';
                var FBPic       = 'http://example.com/img/your-custom-image.jpg';

                // Open FB share popup
                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) {
                // Action after response
                })
        })

    })( jQuery );

这篇关于Facebook的Feed对话框中的“图片"已弃用,我该如何发布图片链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 18:57
查看更多