使用facebooks本机按钮而不是自己的图像html元素触发共享按钮

时间:2015-01-22 13:39:03

标签: facebook share

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Feed Dialog Page</title>
</head>
<body>

   //I can trigger the FB.ui with this image here but thatś not what I want. I want to trigger the FB.ui with the test function with the native facebook-share button with the class fb-share-button below.

<img id="share_button"  onclick="test();" src="">
<script>
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '',
      xfbml      : true,
      version    : 'v2.2'
    });
  };

  (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'));
   

function test(){
    FB.ui({
     method: 'share_open_graph',
     action_type: 'og.likes',
     action_properties: JSON.stringify({
      object:'https://developers.facebook.com/docs/',
     })
    }, function(response){});
}
</script>


<div class="fb-share-button" data-href="http://testgenerall.webhomeschool.de/test_fb_ui.html" data-redirect="http://testgenerall.webhomeschool.de/test_fb_ui.html" data-layout="button_count"></div>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

这是不可能的,您只能使用共享按钮的图像,但是您无法使用共享按钮插件来触发您自己的自定义功能。