【问题标题】:How to share message via LInkedin如何通过 LInkedin 分享信息
【发布时间】:2019-07-04 22:07:15
【问题描述】:

我正在尝试创建通过 Linkedin 分享的分享按钮,包括标题和描述

我发现可以通过自定义 URL 进行操作,如下所示: https://www.linkedin.com/shareArticle?mini=true&url=http://developer.linkedin.com&title=LinkedIn%20Developer%20Network&summary=My%20favorite%20developer%20program&source=LinkedIn

请求参数:

如果我尝试为我的事业制作它,它只分享链接而不是标题和描述:

https://www.linkedin.com/shareArticle?mini=true&url=https://www.athenatools.com/&title=ATHENA%20TOOLS&summary=THAT%20IS%20MY%20EXAMPLE&source=athenatools

我从这里获取的信息:https://developer.linkedin.com/docs/share-on-linkedin

总之,我的问题是如何在我想要的网站上分享标题、描述和链接

【问题讨论】:

    标签: javascript html url linkedin share-button


    【解决方案1】:

    你的url和一些参数需要进行urlencoded,比如url参数应该是这样的:https%3A%2F%2Fathenatools.com%2F

    你可以使用这个工具:https://www.url-encode-decode.com/

    【讨论】:

    • 或者不使用在线转换器,而是在构建 URL 时即时进行,或者在 Javascript 中使用 encodeURI(),或者在生成页面时在服务器上使用您支持的类似功能服务器脚本语言。
    • linkedin.com/… 我做到了,但只得到链接,没有标题和描述
    【解决方案2】:

    正如 Marcin 所说,在将一个 URL 作为参数传递给另一个 URL 的 GET 参数时(不仅在 LinkedIn URL,而且在所有 URL 中),您必须执行 URL encoding。但实际上还有一点需要解决!

    您似乎使用的是旧格式的 LinkedIn 共享 API。自从被 Microsoft 收购后,LinkedIn 的大部分文档(尤其是最新的资料)都可以在 Microsoft 开发人员网站上找到。看看:Official Microsoft LinkedIn Sharing Documentation。所以,你的 URL 应该看起来像......

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

    您还尝试发送title 和其他参数,但唯一支持的参数是url。

    不过,您可能想分享标题等信息,对吧?在这种情况下,请在 HTML 页面的 <head> 块中设置 og: 标记,如下所示...

    • <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" />

    来源:LinkedIn Documentation: Making Your Website Shareable on LinkedIn。

    og: 标签确实是一种良好的标准做法,为什么不呢?如果您想知道您是否正确设置了所有内容,LinkedIn 也为您提供了帮助:

    LinkedIn Post Inspector :检查您要共享的 URL,确保所有配置正确,带有正确的 og: 标签等。输入您要共享的 URL,即example.com/YourSite/ThisPageIsWhatYouWantToBeSharedOnLinkedIn.

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-22
      • 2014-12-25
      • 2020-12-09
      • 2018-10-04
      • 1970-01-01
      • 2014-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多