How to make a custom LinkedIn share button

前端 未结 10 1549
情书的邮戳
情书的邮戳 2020-12-02 05:47

I need to be able to add sharing functionality to my custom button. I\'m not interested with their generator, as I can\'t change LinkedIn image there. I want to use my own i

相关标签:
10条回答
  • 2020-12-02 06:36

    Official LinkedIn API for sharing:

    https://developer.linkedin.com/docs/share-on-linkedin

    Read Terms of Use!

    Example link using "Customized URL" method: http://www.linkedin.com/shareArticle?mini=true&url=https://stackoverflow.com/questions/10713542/how-to-make-custom-linkedin-share-button/10737122&title=How%20to%20make%20custom%20linkedin%20share%20button&summary=some%20summary%20if%20you%20want&source=stackoverflow.com

    You just need to open it in popup using JavaScript or load it to iframe. Simple and works - that's what I was looking for!

    EDIT: Video attached to a post:

    I checked that you can't really embed any video to LinkedIn post, the only option is to add the link to the page with video itself.

    You can achieve it by putting YT link into url param:

    https://www.linkedin.com/shareArticle?mini=true&url=https://www.youtube.com/watch?v=SBi92AOSW2E

    If you specify summary and title then LinkedIn will stop pulling it from the video, e.g.:

    https://www.linkedin.com/shareArticle?mini=true&summary=youtube&title=f1&url=https://www.youtube.com/watch?v=SBi92AOSW2E

    It does work exactly the same with Vimeo, and probably will work for any website. Hope it will help.

    EDIT 2: Pulling images to the post:

    When you open above links you will see that LinkedIn loads some images along with the passed URL (and optionally title and summary).

    LinkedIn does it automatically, and you can read about it here: https://developer.linkedin.com/docs/share-on-linkedin#opengraph

    It's interesting though as it says:

    If Open Graph tags are present, LinkedIn's crawler will not have to rely on it's own analysis to determine what content will be shared, which improves the likelihood that the information that is shared is exactly what you intended.

    It tells me that even if Open Graph information is not attached, LinkedIn can pull this data based on its own analysis. And in case of YouTube it seems to be the case, as I couldn't find any Open Graph tags added to YouTube pages.

    0 讨论(0)
  • 2020-12-02 06:41

    Its best to use customize url approach. And its the easiest. Found this one. It will open a popup window and you dont need any bs authentication issues because of w_share and all.

    <a href="https://www.linkedin.com/shareArticle?mini=true&url=http://chillyfacts.com/create-linkedin-share-button-on-website-webpages&title=Create LinkedIn Share button on Website Webpages&summary=chillyfacts.com&source=Chillyfacts" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;">
      <img src="http://chillyfacts.com/wp-content/uploads/2017/06/LinkedIN.gif" alt="" width="54" height="20" />
    </a>

    Just change the url with your own url. Here is the link http://chillyfacts.com/create-linkedin-share-button-on-website-webpages/

    0 讨论(0)
  • 2020-12-02 06:42

    The API is updated now and the previous API will be deprecated on 1st March, 2019.

    To create a custom Share button for LinkedIn, you need to make POST calls now. You can read the updated documentation here for doing so.

    0 讨论(0)
  • 2020-12-02 06:43

    LinkedIn revised their site recently, so there are a ton of old links just redirecting to the developer support homepage. Here is an updated link to the relevant page on LinkedIn's support site (as of Feb 16, 2015): https://developer.linkedin.com/docs/share-on-linkedin

    0 讨论(0)
  • 2020-12-02 06:44

    As of April 2017, this is the current URL used for sharing:

    https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network &summary=My%20favorite%20developer%20program&source=LinkedIn

    0 讨论(0)
  • 2020-12-02 06:47

    LinkedIn has updated their api and the sharing url's no longer works. Now you can only use the url query parameter. Any other parameter is going to be removed from the url by LinkedIn.

    Now you're forced to use oAuth and interact with the linkedin API to share content on behalf of a user.

    0 讨论(0)
提交回复
热议问题