Problems uploading images with “Share on LinkedIn”

2019-08-16 02:12发布

So I am trying to post an image to my personal page through the new v2 LinkedIn API. I am sending the following data:

{"author":"urn:li:person:MYID","lifecycleState":"PUBLISHED","visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"},"specificContent":{"com.linkedin.ugc.ShareContent":{"shareMediaCategory":"IMAGE","shareCommentary":{"text":"Hello. Just testing the LinkedIn API."},"media":[{"status":"READY","originalUrl":"https:\/\/www.bbc.co.uk\/news","title":{"text":"BBC news"},"description":{"text":"A test post about BBC news"},"media":"urn:li:digitalmediaAsset:C4E22AQFmydgog-wKTw"}]}}}

As you'll see I've already uploaded the image and have a successful Asset ID and reference.

I get a successful id back from Linkedin: urn:li:share:651159824176993XXX but for some reason my image never appears?? What am I doing wrong?

1条回答
我命由我不由天
2楼-- · 2019-08-16 02:55

Before creating the UGC post referencing the registered asset, you need to make sure that the asset is AVAILABLE, otherwise your image won't appear on LinkedIn.

When registering an asset, it goes through the following phases:

  1. PROCESSING (LinkedIn probably does some optimizations to the image / checks if it's valid)
  2. AVAILABLE (you should be good to go)
  3. CLIENT_ERROR (or some other error I can't remember. Basically you should try it with a different asset)

For my app, before creating the UGC post with the image(s), I make sure the asset(s) is / are AVAILABLE first. How do I do that? By checking the status of each asset every 5 seconds with a timeout of 5 minutes (I tried it with a GIF once and to this day is still processing haha).

Once all assets are AVAILABLE, I create the UGC post referencing them, just like you did in your question.

查看更多
登录 后发表回答