Facebook share with custom parameters with API version 2.9

扶醉桌前 提交于 2019-12-04 10:26:34

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.

Just encounter with this problem myself. After some research I found this solution:

www.facebook.com/sharer.php?caption=[caption]&description=[description]&u=[website]&picture=[image-url]

you can use JavaScript window.open to simulate the behavior like this:

Here is a working example: https://jsfiddle.net/ovidiu_turean/mhuexvjL/

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
  window.open('https://www.facebook.com/sharer.php?title=ThisIsAtitle&description=ThisIsAdesc&u=https://www.google.ro&picture=https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-526588.jpg', 'Share', 'scrollbars=yes,resizable=yes,toolbar=no,menubar=no,scrollbars=no,location=no,directories=no,width=300, height=300, top=300, left=300' );
}
</script>

https://developers.facebook.com/docs/apps/changelog#v2_9

Custom parameters are not possible anymore, shared URLs only take their data from the Open Graph Tags on the website, Open Graph Tags need to be static for each URL. Else, you could share ANY URL with ANY title/description, which could be misleading.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!