链接facebook共享API到按钮图像



我不想使用默认的fb共享按钮,所以我创建了一个按钮,象征fb与漂亮的悬停,现在我想链接到fb共享api。这可能吗?

您可以使用javascript sdk和提要对话框来做到这一点。只需为您的图像分配一个onclick事件,然后调用dialog函数。下面是来自https://developers.facebook.com/docs/reference/dialogs/feed/

的代码片段
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
 <title>My Feed Dialog Page</title>
 </head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script> 
  FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
  function postToFeed() {
    // calling the API ...
    var obj = {
      method: 'feed',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: 'Facebook Dialogs',
      caption: 'Reference Documentation',
      description: 'Using Dialogs to interact with users.'
    };
    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }
    FB.ui(obj, callback);
  }
</script>

最新更新