如何通过LinkedIn API获取企业主页帖子的评论、互动及用户资料?
LinkedIn API: Getting Post Comments, Engagement Data, and Interactive User Profiles
1. Fetching Comments for a Post
Every share from your initial request has an id field (e.g., urn:li:share:123456789). Use this URN to retrieve comments for the post with the comments API:
GET https://api.linkedin.com/v2/comments?q=parent&parent={shareUrn}&count=100
- Swap
{shareUrn}with the actualidvalue from your share object. - Use the
startparameter (e.g.,&start=100) to paginate through more than 100 comments. - The response includes each comment's author URN (
actorfield), which you’ll use to fetch the user’s profile later.
2. Fetching Engagement Data (Likes & Shares)
Likes/Reactions
To get the list of users who reacted to a post (likes, loves, etc.), use the reactions endpoint:
GET https://api.linkedin.com/v2/reactions?q=entity&entity={shareUrn}&count=100
- This returns all reactions along with the reacting user’s URN (
actorfield). - For aggregate counts (total likes, shares, comments), check the
statisticsobject in your original share response—look forlikeCount,shareCount, andcommentCount.
Shares of the Original Post
If you need the actual posts that users shared from your enterprise page, use the shares API with the parentShare parameter:
GET https://api.linkedin.com/v2/shares?q=parentShare&parentShare={shareUrn}&count=100
- This gives you the shared posts, including the owner URN (the user who shared your content).
3. Fetching User Profiles of Interactors
Once you have a user’s URN (from comments, reactions, or shared posts), fetch their profile data using the people API:
GET https://api.linkedin.com/v2/people/{personUrn}
- Replace
{personUrn}with the user’s URN (e.g.,urn:li:person:abc123). - With your current Marketing permissions, you can access public profile fields like name, headline, profile picture, and industry. Getting private data (email, contact info) requires additional scopes (like
r_emailaddress) and may need LinkedIn’s approval.
4. Permission Check
- Your existing Marketing permissions (with scopes such as
r_organization_socialandr_liteprofile) are enough for fetching comments, reactions, shares, and basic user profiles. - Advanced account tiers are only required if you need restricted data (detailed contact info), higher rate limits, or advanced analytics. For public engagement data and basic profiles, no upgrade is necessary.
内容的提问来源于stack exchange,提问作者Rafael Elias
相关产品推荐
相关产品推荐

