在 FB 和 LINKEDIN 上与页面文本一起共享文本?

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

我刚刚偶然发现在 Facebook / LinkedIn 上与文本一起共享文本(标签)。这是我正在尝试做的事情(标签:#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>

不幸的是,这不起作用(难怪!) FB 上有 "Say Something about it" 字段。 我可以向共享按钮添加一段代码,以便该字段将包含文本(非常类似于用于电子邮件发送的 "subject")。

我可以用 Twitter 做到这一点。像这样:

 <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>

虽然我不确定其他服务,但您可以使用此格式自定义 LinkedIn 上的共享文本(请注意,所有 {} 占位符值应替换为 URL 编码值):

<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>

例如

<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>

可在此处找到有关共享内容的完整文档:https://developer.linkedin.com/docs/share-on-linkedin

脸书

使用分享器,只能指定url,像这样...

https://www.facebook.com/sharer.php?u={url}

来源:Facebook Sharer Documentation.

但是,如果您注册您的应用程序、获取应用程序 ID 并安装 Facebook 共享对话框插件,那么您几乎可以无限制地访问指定共享...

https://www.facebook.com/dialog/share?app_id={app_id}&display={page_type}&href={url}&redirect_uri={redirect_url}

来源:Facebook Dialog Documentation.

LinkedIn

因此,在 LinkedIn 上分享时,您不能真正指定任何 text。您只能设置 url 参数。但是您可以将 og: 标签设置为在您的分享页面中显示 titleimage 等作为预览:

  • <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 Post Inspector.

但是,与 Facebook 类似,如果您注册您的应用程序,获得一个 appid 等,您可以随心所欲地使用这种格式...

"com.linkedin.ugc.ShareContent": {
        "shareCommentary": {
            "text": "Hello World! This is my first Share on LinkedIn!"
        },
        "shareMediaCategory": "NONE"
    }

来源:Microsoft LinkedIn Documentation: Share on LinkedIn.