使用“feed”对话框中的“图片”不推荐如何发布图片链接 [英] With 'picture' in feed dialog deprecated how can I post an image link

查看:156
本文介绍了使用“feed”对话框中的“图片”不推荐如何发布图片链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用Feed对话框,让网站上的用户在他们的Facebook Feed上分享内容。在他们的饲料上,将有一张图片作为我网站上的页面的链接,其下面有一些文本(名称,标题和描述字段)。所有这些 - 图片,名称,标题和描述现在已被弃用,并于7月17日停止工作。有没有其他方法可以使用不同的方法来实现此功能?

I've been using the 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?

推荐答案

您需要使用Open Graph操作方法此页面的底部在这里的FB开发文档

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


使用 FB.ui 功能与
share_open_graph方法参数共享Open Graph故事。

Trigger a Share Dialog using the FB.ui function with the share_open_graph method parameter to share an Open Graph story.

在您的代码中尝试这一点,以指定您的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.stopPropagation();
            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 );

这篇关于使用“feed”对话框中的“图片”不推荐如何发布图片链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆