Sharing a TEXT alonsgide with a page text on FB and LINKEDIN?

你。 提交于 2021-02-05 09:30:48

问题


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:


Facebook

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.

LinkedIn

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!