问题
I've just stumbled upon sharing a text (a hashtag) togeher with a text on Facebook / LinkedIn. Here is hwat I am trying to do (hashtag: #STUFF):
<li class="facebook"><a target="_blank" href="http://www.facebook.com/share.php?u=<?php echo '#STUFF'. urlencode(get_the_permalink()); ?>">facebook</a></li>
THIS, unfortunately doesn't work (no wonder!) There is "Say Something about it" field on FB. Can I add a piece of code to the sharing button so that field will contain text (pretty much like with "subject" for email sending).
I am able to do that with Twitter. Like this:
<li class="twitter"><a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo urlencode(get_the_title() . ', #STUFF'); ?>&url=<?php echo urlencode(get_the_permalink()); ?>&original_referer=<?php ?>">twitter</a></li>
回答1:
While I am uncertain about the other services, you can customize the share text on LinkedIn using this format (Note that all of the {}
placeholder values should be replaced with URL-encoded values):
<a href="https://www.linkedin.com/shareArticle?mini=true&url={URL to share}&title={article title}&summary={article summary}&source={your app/website name}">Link text</a>
E.g.
<a href="https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn">Link text</a>
Complete documentation for sharing content can be found here: https://developer.linkedin.com/docs/share-on-linkedin
回答2:
Using sharer, you can only specify url
, like so...
https://www.facebook.com/sharer.php?u={url}
Source: Facebook Sharer Documentation.
BUT, if you register your app, get an app id, and install the Facebook share dialog plugin, then you have virtually unlimited access to specify sharing...
https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}
Source: Facebook Dialog Documentation.
So, you cannot really specify any text
when sharing on LinkedIn. You can only set the url
param. But you can set the og:
tags to show title
, image
, etc., as a preview in your share page:
<meta property='og:title' content='Title of the article"/>
<meta property='og:image' content='//media.example.com/ 1234567.jpg"/>
<meta property='og:description' content='Description that will show in the preview"/>
<meta property='og:url' content='//www.example.com/URL of the article" />
Source: LinkedIn Developer Docs: Making Your Website Shareable on LinkedIn.
Verify that you did it right with: the LinkedIn Post Inspector.
BUT, similarly to Facebook, if you register your app, get an appid, etc., you can use this format fully to your heart's content...
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Hello World! This is my first Share on LinkedIn!"
},
"shareMediaCategory": "NONE"
}
Source: Microsoft LinkedIn Documentation: Share on LinkedIn.
来源:https://stackoverflow.com/questions/32030437/sharing-a-text-alonsgide-with-a-page-text-on-fb-and-linkedin