3

我想實現像facebook和分享自定義文本的twitter。 (意味着文字已經預定義)。我怎樣才能做到這一點。如何實現像facebook和分享twitter與自定義文本導軌3

我嘗試這些: -

gem 'facebook_share' 
addthis.com // as their promotion they are adding @addthis which is obvious for using there services but i want to have that. 
+0

@AndrewMarshall查看編輯部分.. – 2011-04-05 05:33:11

回答

4

嘗試這兩種。無需包含任何SDK,插件等。只需複製並粘貼到你的視圖文件。

爲Facebook: -

<iframe src="http://www.facebook.com/plugins/like.php?href=google.com&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=recommend&amp;font=arial&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe> 

Twitter的: -

<a href="http://twitter.com/share" class="twitter-share-button" data-url="google.com" data-text="this is the custom text." data-count="horizontal" data-via="MyTwitterAccountUsername">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> 
0

Twitter的:

<a href='https://twitter.com/share?url=google.com&text=Signup>Tweet</a> 
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src='//platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document,'script','twitter-wjs');</script> 

對於Facebook:你可以用飼料的方法API:

function streamPublish(name, hrefTitle, hrefLink, userPrompt){   
      FB.ui({ method : 'feed', 
        message: userPrompt, 
        link : hrefLink, 
        caption: hrefTitle, 
        picture: 'https://www.google.com/images/srpr/logo3w.png' 
      }); 

     } 
     function publishStream(){ 
      streamPublish("Stream Publish", "Google", "http://google.com/", "Check it out"); 
     }