【问题标题】:How to implement like for facebook and share for twitter with custom text in rails 3如何在rails 3中使用自定义文本为facebook实现like并为twitter分享
【发布时间】:2011-07-29 16:32:53
【问题描述】:

我想为 facebook 实现 like 并使用自定义文本为 twitter 分享。 (意味着文本已经预定义)。我该怎么做。

我试过这些:--

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.

【问题讨论】:

  • @AndrewMarshall 检查编辑部分..

标签: ruby-on-rails ruby-on-rails-3 facebook twitter facebook-like


【解决方案1】:

试试这两个。无需包含任何 sdk、插件等。什么都没有。只需将其复制并粘贴到您的视图文件中即可。

对于脸书:--

 <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>

推特:--

 <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>

【讨论】:

    【解决方案2】:

    推特:

    <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:您可以使用 feed 方法 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");
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多