Daniel Bonnell
Daniel Bonnell

Reputation: 4997

URL for sharing a LinkedIn post

What is the URL structure for directly linking to a LinkedIn post. On the site itself there is no option to link to a post directly, only to share one of Twitter or Facebook. I've tried sharing a post on Twitter and copying the link from the Tweet, but that link always goes to whatever link was in the original LinkedIn post rather than to the post itself (which makes sense).

I've also tried the following link structure, which seemed to work before, but is not working anymore. Whenever I click a link like this, I get an error message saying the post doesn't exist, even though it clearly does.

https://www.linkedin.com/nhome/updates?topic=POST_ID

There is nothing in the API docs about linking to a specific post, which suggests that either the feature doesn't exist, or is not widely supported.

Upvotes: 1

Views: 5109

Answers (1)

Daniel Bonnell
Daniel Bonnell

Reputation: 4997

After digging through the object returned by the Linkedin gem when posting a share to a company page, I found the url structure. It was buried pretty deep, but it does exist.

https://www.linkedin.com/company/COMPANY_ID/comments?topic=SHARE_ID&type=U&scope=COMPANY_ID&stype=C&a=PBfw

COMPANY_ID is the id of the company page (not the name). SHARE_ID is the id of the share/post.

Using the LinkedIn gem, you can get this link by calling JSON.parse(post.body)['updateUrl']. To get just the post id you can call JSON.parse(post.to_json)['location'][0].split('/')[-1].

I hope this helps someone out because I spent way too much time struggling with this problem.

Upvotes: 3

Related Questions