我已经使用下面描述的创建图像共享 api 实现了在 linkedin 上共享图像帖子的所有三个步骤。但创建的帖子在我的 linkedin 提要/帖子或最近的活动中不可见。
https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share https://learn.microsoft.com/en-us/linkedin/consumer/integrations/self-serve/share-on-linkedin#create-an-image-share
我第一次创建帖子时使用 API 可见并且它返回了{"id":"urn:li:share:6521244543193575424"}
已发布可见帖子网址:https://www.linkedin.com/feed/update/urn:li:share:6520269375554060288/ https://www.linkedin.com/feed/update/urn:li:share:6520269375554060288/
第二次使用下面的相同代码创建时,会返回类似的响应,其中包含创建的帖子 ID 和 201 创建的状态代码,但帖子在 linkedin 上不可见。
例如这篇文章https://www.linkedin.com/feed/update/urn:li:share:6521027773560119296 https://www.linkedin.com/feed/update/urn:li:share:6521027773560119296
我检查了我的 linkedin 个人资料,但在任何地方都找不到我的帖子。
我正在使用的用于发布的最终功能的代码(使用上面的文档链接创建图像共享的第三步):
def share_on_linkedin(self, asset, title, description):
# asset = "urn:li:digitalmediaAsset:C5122AQEAatG9rZ7MhQ"
headers = {
'Content-Type':'application/json',
'X-Restli-Protocol-Version': '2.0.0',
'Authorization': 'Bearer '+Constant.ACCESS_TOKEN
}
payload = {
"author": "urn:li:person:leRbOTCFKK",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": description
},
"shareMediaCategory": "IMAGE",
"media": [
{
"status": "READY",
"description": {
"text": "Center stage!"
},
"media": asset,
"title": {
"text": title
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
try:
data = json.dumps(payload, sort_keys=True, indent=4)
url = "https://api.linkedin.com/v2/ugcPosts"
response = requests.post(url , headers=headers, data=data )
print response.text
result = json.loads(response.text)
if response.status_code==200 or response.status_code==201:
print response.text
print response.headers
posted_url = "https://www.linkedin.com/feed/update/"+result['id']
print posted_url
return True, posted_url
return False, None
except Exception as e:
print e
Output:
{"id":"urn:li:share:6521245116978552832"}
{'Content-Length': '41', 'X-RestLi-Protocol-Version': '2.0.0', 'X-Li-Pop': 'prod-tmu1', 'X-LI-ResponseOrigin': 'RGW', 'X-RestLi-Id': 'urn:li:share:6521245116978552832', 'X-LI-UUID': 'aKr30Z+1kxWAo4kEzioAAA==', 'X-LI-Route-Key': '"b=SB83:g=115:u=3:i=1554785994:t=1554872227:s=AQH26er48VUD_YiXQIgAqujebI53eswQ"', 'X-Li-Fabric': 'prod-lsg1', 'Connection': 'keep-alive', 'Location': '/ugcPosts/urn%3Ali%3Ashare%3A6521245116978552832', 'Set-Cookie': 'lidc="b=SB83:g=115:u=3:i=1554785994:t=1554872227:s=AQH26er48VUD_YiXQIgAqujebI53eswQ"', 'Date': 'Tue, 09 Apr 2019 04:59:55 GMT', 'X-LI-Proto': 'http/1.1', 'Content-Type': 'application/json'}
从上面成功响应构建的发布 URL 是:https://www.linkedin.com/feed/update/urn:li:share:6521245116978552832 https://www.linkedin.com/feed/update/urn:li:share:6521245116978552832
但这个帖子是看不到的。
任何人都可以帮我解决这个问题吗?
Thanks!