Linkedin API 发布预览问题

问题描述 投票:0回答:2

我联系了 Linkedin 寻求这方面的支持,他们建议在这里发帖。 所以向市场上的#linkedin 开发人员询问。

我的问题是 Linkedin Rest API。 API 是:https://api.linkedin.com/v2/ugcPosts 您可以在此处找到有关 API 的更多信息:https://learn.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 information 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 上发布时不会生成网址预览,如附图所示:current_wrong_preview.png 我还检查了 Linkedin 后检查器工具中的 URL,在那里它正在生成正确的预览,如附图所示:post-preview-in-linkedin-post-inspector.png

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

另请注意,通过 Linkedin 直接发布链接时,会生成正确的预览,但只有在我使用 API 时才会出现问题。 通过 API 发布时出现问题的示例 URL 为: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 帖子预览图

linkedin-api linkedin-jsapi
2个回答
2
投票

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

对于我们的回复延迟深表歉意。我们目前的支持量高于预期。 我很好奇您从 API 创建的共享中看到的问题是否来自我们最近对文章类型帖子所做的更改。 https://learn.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, title, 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, title, or thumbnail fields, rather than rely on automatic preview. Use the Post Inspector tool to determine what the LinkedIn URL Preview looks like.

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


0
投票

对我来说仍然不起作用。

$params = [
                "author" => "urn:li:person:{$this->urn}",
                "lifecycleState" => "PUBLISHED",
                "specificContent" => [
                    "com.linkedin.ugc.ShareContent" => [
                        "shareCommentary" => [
                            "text" => "Article title"
                        ],
                        "shareMediaCategory" => "ARTICLE",
                        "media" => [
                            [
                                "status"=> "READY",
                                //"description"=> [
                                //    "text" => "{$article->description} {$hashtags}"
                                //],
                                "originalUrl"=> $url,
                                //"title"=> [
                                //    "text"=> "{$article->title}"
                                //]
                            ]
                        ],
                    ],
                ],
                "visibility" => [
                    "com.linkedin.ugc.MemberNetworkVisibility" => "PUBLIC"
                ]
            ];
© www.soinside.com 2019 - 2024. All rights reserved.