我有一个内置于 react-native 的应用程序,我需要在其中分享带有预定义内容的 LinkedIn 帖子。
我使用“react-native-share”在 LinkedIn 上分享内容,但它不起作用。我怎样才能做到这一点?
提前致谢。
最佳答案
LinkedIn 只支持向其传递一个参数,即 url
参数。它看起来像这样......
https://www.linkedin.com/sharing/share-offsite/?url={url}
来源:Official LinkedIn Sharing Documentation。
以下参数将不起作用:summary
、title
、source
等。除 url
之外的任何参数。
要分享到 LinkedIn,只需创建一个指向上述格式化 URL 的 <a href>
元素,并绝对确保对您的 {url}
进行 URL 编码。
不过,根据已接受的答案,您可能想分享 title
和 summary
。您不能使用 GET
-data 来做到这一点,但是您可以使用 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 Developer Docs: Making Your Website Shareable on LinkedIn。
如果您不确定自己是否按照 LinkedIn 文档正确创建了共享 URL,您可以在此处测试页面的 URL 以查看共享时的外观: LinkedIn Post Inspector 。
关于react-native - 使用 React Native 在 LinkedIn 上分享帖子,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61076706/