如何在 Rails 3 中使用自定义文本实现 facebook 的点赞和 twitter 的分享

发布于 2024-10-31 01:27:49 字数 266 浏览 0 评论 0原文

我想为 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.

I want to implement like for facebook and share for twitter with custom text. (Means text is already predefined). How can i do that.

I tried these:--

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

红玫瑰 2024-11-07 01:27:49

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

脸书:--

 <iframe src="http://www.facebook.com/plugins/like.php?href=google.com&layout=standard&show_faces=true&width=450&action=recommend&font=arial&colorscheme=light&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>

Try these two. No need to include any sdk, plugin etc. Nothing. Just copy and paste it on ur view file.

For facebook:--

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

for 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>
美羊羊 2024-11-07 01:27:49

对于 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:您可以使用 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");
        }

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

For facebook: you can use the feed method 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");
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文