【问题标题】:tweet this link in rails app在 Rails 应用程序中发布此链接
【发布时间】:2011-03-24 14:01:27
【问题描述】:

我很惊讶我在 google 上找不到它,添加“tweet”此链接以向用户的 twitter 帐户发布 url 和描述的最佳方式是什么?

【问题讨论】:

    标签: ruby-on-rails twitter


    【解决方案1】:

    “tweet this link”功能非常简单,不需要额外的 Rails 功能。很简单:

    <a href=http://twitter.com/home?status=Name_and_Address_of_the_twitter_post_that_you_want_everyone to_see_on_twitter>Add to Twitter</a>
    

    要使用 Rails 代码,应该是这样的:

    = link_to "tweet me", "http://twitter.com/home?status=#{@post.short_name} #{post_url(@post)}"
    

    一些备注:

    • 状态不应超过 140 个字符(您可以使用外部服务作为 bit.ly,也可以编写自己的控制器来回答小地址并重定向到帖子)

    • 您还可以实现一种跟踪机制,该机制可以检测有多少用户点击了“tweet this”链接

    【讨论】:

    • 谢谢。是的,我还指的是跟踪链接,就像 digg 使用 javascript 包含一样
    • 我可以为facebook和linkedin做同样的事情吗?
    • 有没有办法可以从 twitter 帖子的文本中删除 _
    【解决方案2】:

    接受的答案曾经对我有用,但在某个时候停止了。像这样的链接现在对我有用:

    https://twitter.com/intent/tweet?text=Some%20description&url=https://example.com/someurl
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      相关资源
      最近更新 更多