我有一个基于Rails的应用程序,帮助用户提交文章。有没有人知道如何让应用程序中的用户使用他们的Facebook地址在Facebook上分享这些文章?能否提供好的参考或教程?
http://www.facebook.com/sharer.php?u=URL
。这将显示一个带有指向你的图片链接的Facebook分享页面。以下是Ruby on Rails的语法:
<%= link_to image_tag('/images/FaceBookIcon.png'), 'http://www.facebook.com/sharer.php?u='+request.fullpath, :target => :blank %>
<%= link_to('Share on Facebook', 'https://www.facebook.com/dialog/feed?
link=https://developers.facebook.com/docs/reference/dialogs/&
picture=http://fbrell.com/f8.jpg&
name=Facebook%20Dialogs&
caption=Reference%20Documentation&
description=Using%20Dialogs%20to%20interact%20with%20users.&
redirect_uri=https://mighty-lowlands-6381.herokuapp.com/',
:target => :blank %>
<a target="_blank"
href="https://www.facebook.com/dialog/feed
?app_id=134530986736267
&link=<%= request.original_url %>
&name=<%= @article.title%>
&picture=<%=image_url(@article.image)%>
&redirect_uri=http://facebook.com/"
class="icon icon-facebook">
</a>
来源:http://bechirsegni.me/articles/how-to-share-articles-on-facebook-without-oauth-access-token
<%= link_to "https://www.facebook.com/sharer/sharer.php?u=#{article_url(@article)}", title: 'Share Me!' do %>
<i class="huge facebook icon" data-content="Share Me!"></i>
<% end %>