Facebook与API版本2.9共享自定义参数 [英] Facebook share with custom parameters with API version 2.9

查看:221
本文介绍了Facebook与API版本2.9共享自定义参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Facebook上分享一个包含自定义标题,图片和说明的测验结果。在4月18日更新到2.9版之前,他们完美地工作。

I need to share a result of a quiz on facebook containing a custom title, picture and description. Wich worked perfect before update to version 2.9 on April 18.

但它不能与版本2.9一起使用。所以我错过了那里的东西?或者Facebook不希望我们在2017年分享我们网站的自定义Facebook Feed?

But it isn't working with Version 2.9. So am I missing out something there? Or does Facebook don't want us to share custom Facebook Feeds of our websites in 2017?

对于我的安装程序的测试Facebook订阅我严格按 Facebook Developers Documentation

For my Setup for a test facebook feed I coded strictly with Facebook Developers Documentation.

Facebook Changelog v2.9 说参数图片,名称,描述和标题是不支持。

Facebook Changelog v2.9 says parameter picture, name, description and caption are not supported anymore.

我的fb api init:

My fb api init:

<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '*APP-ID*',
      xfbml      : true,
      version    : 'v2.9'
    });
    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>

我的fb-share电话:

My fb-share call:

<script>
    $(document).ready(function() {
        $('#fbButton').click(function() {
            FB.ui({
                method: 'feed',
                link: '*URL*',
                caption: 'An example caption',
                picture: '*URL*/img/content4.jpg',
                name: 'An example name',
                description: 'An example description'
            }, function(response){});
        });
    });
</script>

因此,我得到一个Facebook饲料没有任何图片或描述。唯一的事情是标题(< head> 中定义的页面的标题与< title>

As a result I get a facebook feed without any picture or description. The only thing is a title (the title of page defined in the <head> with <title>).

显然,通常的程序不再工作。

Obviously, the usual procedure isn't working anymore.

所以有什么办法使用新的Facebook API 2.9版分享自定义文本与自定义图片

有没有解决方法?或者是v2.9是不可能的,因为Facebook不希望我们分享这样的自定义Feed? (无论什么原因..)

Is there any workaround? Or is it just impossible with v2.9, because facebook doesn't want us to share custom feeds like this? (for whatever reason..)

(不,我不能使用og:tags)

(and no, I cannot use og:tags)

推荐答案

我只是试图使用开放图表法而不是feed和override og属性,见下文:

I just tried to use open graph method instead of feed and override og properties, see below:

FB.ui({
            method: 'share_open_graph',
            action_type: 'og.shares',
            action_properties: JSON.stringify({
                object : {
                   'og:url': 'http://astahdziq.in/', // your url to share
                   'og:title': 'Here my custom title',
                   'og:description': 'here custom description',
                   'og:image': 'http://apps.investis.com/Dharmendra/fbPOC/south.jpg'
                }
            })
            },
            // callback
            function(response) {
            if (response && !response.error_message) {
                // then get post content
                alert('successfully posted. Status id : '+response.post_id);
            } else {
                alert('Something went error.');
            }
        });

这对我有用,因为我可以发布带有标题和描述的自定义图片。

this worked for me as I am able to post custom image with title and description.

这篇关于Facebook与API版本2.9共享自定义参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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