在facebook帖子中包含句子

时间:2011-01-28 15:05:25

标签: facebook

您好 我想在用户的新闻Feed中发布一个句子和链接,但是如何将文本和链接一起包含在内。 这是我正在使用的链接:

<script type="text/javascript">
  function fbs_click() {
    u = location.href; 
    t = document.title; window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436'); 
    return false;
   }
</script>
<style>
  html .fb_share_link {
    padding:2px 0 0 20px;
    height:16px;
    background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981)
    no-repeat top left;
  }
</style>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=http://www.mywebsite.com" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share on Facebook</a>

提前致谢,Laziale

1 个答案:

答案 0 :(得分:0)

你必须使用PHP链接吗?似乎使用官方javascript客户端库可能更容易:https://github.com/facebook/connect-js。以下是示例代码:

  FB.ui(
    {
        method: 'stream.publish',
        attachment: {
            name: 'JSSDK',
            caption: 'The Facebook JavaScript SDK',
            description: (
          'A small JavaScript library that allows you to harness ' +
          'the power of Facebook, bringing the user\'s identity, ' +
          'social graph and distribution power to your site.'
        ),
            href: 'http://fbrell.com/'
        },
        action_links: [
        { text: 'fbrell', href: 'http://fbrell.com/' }
      ]
    },
    function (response) {
        if (response && response.post_id) {
            alert('Post was published.');
        } else {
            alert('Post was not published.');
        }
    }
  );