共享时LinkedIn URL预览不起作用

时间:2020-06-29 23:49:47

标签: node.js linkedin

我创建了一个简单的Node.js Web服务器,以在浏览器中呈现html内容。具体来说,该html包含用于在社交媒体上共享的元标记,以便在FB,Twitter,LinkedIn等社交平台上共享网站链接后就可以启用URL预览。

我已经添加了开放图标记以在返回的html内容中共享。它适用于FB和Twitter,但显示错误消息“我们在尝试检查URL时遇到服务器错误”。作为回应。

这是带有虚拟端点的服务器代码。

compare2

网站链接:https://whispering-woodland-66525.herokuapp.com/dummy(页面为空,请检查“检查”的头部)

Facebook共享调试器的响应:https://developers.facebook.com/tools/debug/?q=http%3A%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

LinkedIn邮政检查员的回复:https://www.linkedin.com/post-inspector/inspect/https:%2F%2Fwhispering-woodland-66525.herokuapp.com%2Fdummy

我已经尝试过多次刷新Post Inspector页面,并向Post Inspector中的url中添加一个伪查询参数,以防止提供缓存的内容,但是事情没有解决。

我无法理解代码中是否有错误或遗漏,或者是LinkedIn网络爬虫的问题。

1 个答案:

答案 0 :(得分:2)

我相信LinkedIn Post Inspector期待完整的HTML文档。考虑将元数据包装到文档的标题中。尝试返回:

<!DOCTYPE html>
  <html lang="en">
    <head>
       <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <title>Dummy Endpoint</title>
       <meta name="type" content="article" />
       <meta name="title" content="Dummy Endpoint"/>
       <meta name="description" content="Used for testing"/>
       <meta name="image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:type" content="article"/>
       <meta property="og:title" content="Dummy endpoint"/>
       <meta property="og:description" content="Used for testing"/>
       <meta property="og:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure_url" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:secure" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta property="og:image:width" content="600" />
       <meta property="og:image:height" content="450" />
       <meta name="twitter:title" content="Dummy Endpoint"/>
       <meta name="twitter:description" content="Dummy endpoint"/>
       <meta name="twitter:image" content="https://www.kindpng.com/picc/m/252-2524695_dummy-profile-image-jpg-hd-png-download.png"/>
       <meta name="twitter:card" content="summary"/>
   </head>
</html>