skip to Main Content

Our application lets an admin create a suggested social post for all of the members of his or her organization. The admin will insert a URL in our system and our platform creates a unique URL for each member. This is a link with a 302 redirect to the original link. It works similar to Bit.ly. When the member gets the suggested post he/she can create his/her own content for the post and url and approve for posting via the LinkedIn API. That all works perfectly.

As an example the share url could be https://example.com

  • Member one gets: https://yip.sh/1234
  • Member two gets: https://yip.sh/4321
  • Member three gets: https://yip.sh/4444

The PROBLEM: Some (a minority) of the member’s posts do not share the meta image for the url. The majority of the social posts work and show a meta image so that tells me both the 302 redirect and the destination url are working correctly. I also have tried the urls from the post that do not work in the LinkedIn post inspector and the meta image shows up there.

My ASSUMPTION: Sometimes pulling the meta image takes a little longer than LinkedIn wants to wait and since each URL is unique it needs to check each time.

Possible SOLUTION: Automated ping of Linkedin post inspector to cache image before the share. This was what we did with Facebook when we had a similar problem. I have not found a way to do that though with LinkedIn.

Just to show the code we are using to share the post. But as I mentioned above this is working a majority of the time.

pass_the_hash = {
      "author": "urn:li:person:#{@social_identity.uid}",
      "lifecycleState": "PUBLISHED",
      "specificContent": {
        "com.linkedin.ugc.ShareContent": {
          "shareCommentary": {
            "text": "My Comment"
          },
          "shareMediaCategory": "ARTICLE",
          "status" => "READY", 
          "originalUrl" => "https://yip.sh/1234"
        }
      },
      "visibility": {
        "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
      }
    }

Has anyone seen a similar issue with LinkedIn Share API not showing meta image consistently? Or possibly know of a way to automate usage of the post inspector?

2

Answers


  1. To quote LinkedIn…

    After updating your website with perfect preview content and image, if you try sharing your website link you will still see old preview content and image. That’s because LinkedIn caches link preview content for 7 days. Source: Official LinkedIn Documentation.

    As you and they state, you can use the LinkedIn Post Inspector to refresh the cache. If you wanted to go the approach of pinging/curling LinkedIn, you can do…

    https://www.linkedin.com/sharing/share-offsite/?url={yourlURL}
    

    For instance, seems to work for getting info from the LinkedIn share API for GitHub.

    Of course, you do also have the less-desirable option of waiting 7 days, although it is nice to know that it eventually works itself out by itself.

    Login or Signup to reply.
  2. In the ugcPosts endpoint of LinkedIn shares API, there are some changes that are causing these issues. You will need to make changes to your code and add extra key for thumbnails like below:

    {
                            "author": "'.$ownerURN.$page_id.'",
                            "lifecycleState": "PUBLISHED",
                            "specificContent": {
                                "com.linkedin.ugc.ShareContent": {
                                    "shareCommentary": {
                                        "text": "'.$text.'"
                                    },
                                    "shareMediaCategory": "ARTICLE",
                                    "media": [
                                        {
                                            "status": "READY",
                                            "description": {
                                                "text": "'.$linkDescription.'"
                                            },
                                            "originalUrl": "'.$href.'",
                                            "title": {
                                                "text": "'.$linkTitle.'"
                                            },
                                            "thumbnails": [{
                                                    "url": "'.$imageHref.'"
                                                }]
                                        }
                                    ]
                                }
                            },
                            "visibility": {
                                "com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
                            }
                        }
    

    I hope this is useful to people who are facing issues with the linkedIn Shares API now. I know this question is old but we faced this issue for a few days and the API documentation is not pointing out the issues.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search