2011-01-28 45 views
0

你好 我想和链接一起在用户的新闻提要中发表一个句子,但是我怎样才能把这个文本和链接一起包括进去。 这是我使用的链接:在Facebook上加上句子

<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

回答

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.'); 
     } 
    } 
);