通过Facebook,LinkedIn和Google Plus分享

时间:2014-10-29 18:04:41

标签: ruby-on-rails ruby twitter google-plus sharing

我想要一个部分,用户可以通过我们的应用在不同的社交媒体平台上分享特定链接。我有Twitter链接正常工作,但Facebook,LinkedIn和G +只是共享URL而不是自定义消息。

微博

a.twitter-share-button href="http://twitter.com/intent/tweet?source=sharethiscom&text=BlahBlahBlah&url=http://#{Figs.ms.url}/#{@app.uuid}" target="_blank"

a.fb-share-button href="https://www.facebook.com/sharer.php?u=http://#{Figs.ms.url}/#{@app.uuid}&t=BlahBlahBlah target="_blank"

LinkedIn

a.linkedin-share-button href="https://www.linkedin.com/cws/share?url=http://#{Figs.ms.url}/#{@app.uuid}&summary=BlahBlahBlah” target="_blank"

G +

a.gplus-share-button href="https://plus.google.com/share?url=http://#{Figs.ms.url}/#{@app.uuid}" target="_blank"

我希望自定义消息是BlahBlahBlah,所以当他们点击任何这些链接时,它会填写自定义消息并包含链接。

2 个答案:

答案 0 :(得分:0)

当前页面网址为(request.original_url)

  1. 对于Facebook,您可以执行以下操作:有关详细信息,请查看docs以获取更多详细信息:
  2.   

    %a.fb-share-button {:href =>   " https://www.facebook.com/dialog/share?app_id=# {APP_ID}&安培;显示弹出=&安培; HREF =#{URL_TO_SHARE}&安培; REDIRECT_URI =#{request.original_url}&#34 ;,   角色:" menuitem",tabindex:" -1",target:" _blank"}

    您可以通过将页面标题,说明和预览照片添加到URL_TO_SHARE元标记来自定义它们。查看Open Graph Object Meta Tags了解详情。

    %meta{:content => "1234567890", :property => "fb:app_id"}/
    %meta{:content => "http://samples.ogp.me/136756249803614", :property => "og:url"}/
    %meta{:content => "Chocolate Pecan Pie", :property => "og:title"}/
    %meta{:content => "https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpa1/t39.2178-6/851565_496755187057665_544240989_n.jpg", :property => "og:image"}/
    
    1. For Linkedin
    2.   

      %a {:href =>   " http://www.linkedin.com/shareArticle?mini=true&url=# {URL_TO_SHARE}&安培;标题=#{TILTE}&安培;总结=#{内容}&安培;源= www.YOUR_DOMAIN.com&#34 ;,   角色:" menuitem",tabindex:" -1",target:" _blank"}

答案 1 :(得分:0)

Twitter: Official Twitter Share Documentation

https://twitter.com/intent/tweet?url={url}&text={title}&via={user_id}&hashtags={hash_tags}

Facebook Official Facebook Dialog Documentation / Official Facebook Sharer Documentation

如果您有API密钥...

https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}

如果你不...

https://www.facebook.com/sharer.php?u={url}

已链接: Official LinkedIn Share Documentation

https://www.linkedin.com/sharing/share-offsite/?url={url}

Google +: Official Google+ Share Documentation

N/A : Service disabled.