Linkedin API 发布预览问题

问题描述

我联系了 Linkedin 寻求支持,他们建议在这里发帖。 因此,请咨询市场上的 #linkedin 开发者。

我的问题是 Linkedin Rest API。 API 是:https://api.linkedin.com/v2/ugcPosts 您可以在此处找到有关 API 的更多信息:https://docs.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin

我使用的请求如下面的示例所示:

{
"author": "urn:li:person:8675309","lifecycleState": "PUBLISHED","specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Learning more about LinkedIn by reading the LinkedIn Blog!"
},"shareMediaCategory": "ARTICLE","media": [
{
"status": "READY","description": {
"text": "Official LinkedIn Blog - Your source for insights and @R_666_4045@ion about LinkedIn."
},"originalUrl": "https://blog.linkedin.com/","title": {
"text": "Official LinkedIn Blog"
}
}
]
}[enter image description here][1]
},"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}

在 Linkedin API 最近更新之前一切正常,我在上述请求的“originalUrl”键中传递了我的文章链接,它生成了正确的预览,如名为 old_correct_preview.png 的附件所示

但是现在在 Linkedin 上发布时不会生成 url 的预览,如您在附图中所见:current_wrong_preview.png 我还检查了 Linkedin 后期检查器工具中的 URL,它正在生成正确的预览,如您在附加图像中所见:post-preview-in-linkedin-post-inspector.png

我不认为这是浏览器问题,因为它发生在 Linkedin 本身上。

另请注意,通过 Linkedin 直接发布链接时会生成正确的预览,但只有在我使用 API 时才会出现问题。 通过 API 发布时出现问题的示例网址是:https://chetu.ctnt.co/video/112/ah-290-376-l

我针对这个问题制作了两个视频。

您可以在这里查看它们:

  1. http://integration.blazingsocial.com/linkedin_preview_issue/
  2. http://integration.blazingsocial.com/wp-content/uploads/2021/06/Linkedin-Problem.mp4

enter image description here 当前错误的预览图

enter image description here 旧的正确预览图像

enter image description here 链接的帖子预览图片

解决方法

我就这个问题联系了 LinkedIn,并特别指出了这篇文章和另一篇类似的文章,这是他们给我的回复。我按照他们提到的去做,现在它也对我有用。我只是要粘贴他们给我的回复,希望您可以按照相同的步骤来修复您的代码。

对于我们的回复延迟表示歉意。我们目前的支持量高于预期。 我很好奇您从 API 创建的共享中看到的问题是否来自我们最近对文章类型帖子所做的更改。 https://docs.microsoft.com/en-us/linkedin/marketing/integrations/recent-changes#page-management

What’s happening: Starting May 31,2021,for article type posts the description,title,and thumbnail will be set from LinkedIn’s URL Preview of the URL only if the description,and thumbnail are not provided from the API call. Prior to this change,each field was set from LinkedIn’s URL Preview if the specific field was not set. If a specific representation of the post is desired,set the description,or thumbnail fields,rather than rely on automatic preview. Use the Post Inspector tool to determine what the LinkedIn URL Preview looks like.

总而言之,因为您仍在传递一些字段,所以我们不会抓取图像。因此,如果您删除除了要从呼叫中抓取的链接之外的所有字段,您应该看到图像、标题和描述都被抓取了。因此,现在抓取基本上是一个全有或全无的事情,您要么提供所有信息,要么不提供任何信息,然后让我们的抓取工具完成剩下的工作。 您可以尝试只传递 URL 并让我知道这是否可以为您解决问题吗?