简体   繁体   中英

Sharing via Twitter, Facebook, LinkedIn, and Google Plus

I would like a section where users can share a certain link on different social media platforms from our app. I have the twitter link working properly but Facebook, LinkedIn, and G+ are only sharing the URL and not a custom message.

Twitter

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

Facebook

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"

I'd like the custom message to be BlahBlahBlah so when they click any of these links it would fill out the custom message and include the link.

The current page url is (request.original_url )

  1. For Facebook you can do the following, For more details check the docs for more details:

%a.fb-share-button{:href => " https://www.facebook.com/dialog/share?app_id=# {APP_ID}&display=popup&href=#{URL_TO_SHARE}&redirect_uri=#{request.original_url}", role: "menuitem", tabindex: "-1", target: "_blank"}

You can customize the page title, description, previewed photo by addting them to the URL_TO_SHARE meta tags. Check Open Graph Object Meta Tags for more details.

%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

%a{:href => " http://www.linkedin.com/shareArticle?mini=true&url=# {URL_TO_SHARE}&title=#{TILTE}&summary=#{SUMMARY}&source=www.YOUR_DOMAIN.com", role: "menuitem", tabindex: "-1", target: "_blank"}

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

If you have an API key...

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

And if you don't...

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

LinkedIn: Official LinkedIn Share Documentation

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

Google+: Official Google+ Share Documentation

N/A : Service disabled.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM