我正在尝试使用V2 API重新共享ugcPost。
我已使用v2 / shares完成此任务。我收到内部服务器错误。
有人尝试过吗,请告诉我这是否可行?
答案 0 :(得分:0)
您应该在标题中添加X-Restli-Protocol-Version:2.0.0
答案 1 :(得分:0)
不确定是否可以找到这个数字,但是我花了一段时间,所以我想把它扔在那里,除非其他人遇到这个问题。对我而言,我没有使用responseContext引用父帖子。这才是对我有用的东西。
"author": "urn:li:person:#{uid of user}",
"lifecycleState": "PUBLISHED",
#this part here
"responseContext": {
"parent": "urn:li:share:6577220936284545024",
"root": "urn:li:share:6577220936284545024"
},
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareMediaCategory": "NONE",
"shareCommentary": {
"text": "Comment here about the reshared post."
},
"media": [],
"shareCategorization": {}
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
标题应该是
{
"Authorization" => "Bearer #{token}",
"Content-Type" => 'application/json',
"X-Restli-Protocol-Version" => "2.0.0"
}
答案 2 :(得分:0)
ugcPost的转发应使用ugcPost文档https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/ugc-post-api#schema
中的架构中的“ responseContext”以下是重新共享ugcPost的示例调用:
cURL:
0
Ruby:
public function user() {
return $this->belongsTo('App\Models\User','user_id'); }
PHP:
curl --location --request POST 'https://api.linkedin.com/v2/ugcPosts' \
--header 'x-li-format: json' \
--header 'X-Restli-Protocol-Version: 2.0.0' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ACCESS_TOKEN' \
--data-raw '{ "lifecycleState": "PUBLISHED",
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
},
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareMediaCategory": "NONE",
"shareCommentary": {
"text": ""
}
}
},
"responseContext": {
"parent": "urn:li:ugcPost:123",
"root": "urn:li:ugcPost:123"
},
"author": "urn:li:person:123"
}'