Linkedin Open Graph Sharing not working

亡梦爱人 提交于 2019-12-09 21:36:20

问题


I have a page setup for Open Graph Protocol because our app is built upon Angular 1.x now when we share a URL using LinkedIn. Share Popup opens but it does not crawl open graph tags sometimes and sometimes it shows the proper crawl tags it was working fine till last week. here is the image which shows the preview area:

Scenario for sharing a link:

  1. User comes on our site: www.example.com/event/[EVENT_ID] and clicks share to LinkedIn.
  2. Popups opens using: https://www.linkedin.com/shareArticle?mini=true&url=https://example.com/event/0u83s43rf6r/4295028179 where 4295028179 is event id and 0u83s43rf6r is a random key for sharing because of cache busting.
  3. Now we are using apache mod_rewrite to redirect LinkedIn, Facebook, Twitter bot to our crawler page where Open graph tags are rendered.

Apache Mod Rewrite Settings in .htaccess file

RewriteCond %{HTTP_USER_AGENT} ^(facebookexternalhit/(.*)|Facebot|Twitter(.*)|Pinterest|LinkedIn(.*)|LinkedInBot)$ [NC]

RewriteRule ^(event)/([_0-9a-zA-Z]+)/([0-9]+)$  https://share.example.com/web/crawler/details/$3 [R=301,L]

So the end url becomes when crawler redirect based on USER AGENT where open graph tags are rendered: http://share.example.com/web/crwaler/details/4295028179

Here is the rendered html tags:

<html>
<head>
  <script type="text/javascript">window.location = 'https://example.com/event/236129271' // if it's a browser then redirect it to website</script>
  <meta property="og:title" content="Event Title" />
  <meta property="og:description" content="Event Description" />
  <meta property="og:image" content="Event Thumbnail" />
  <meta name="title" content="LinkedIn Share Test" />
  <meta name="description" content="Event Description" />
  <meta property="og:image:width" content="188" />
  <meta property="og:image:height" content="71" />
  <!-- Twitter Card Working Fine-->
  <meta name="twitter:card" content="summary_large_image">
  <meta name="twitter:title" content="Event Title">
  <meta name="twitter:description" content="Event Description">
  <meta name="twitter:image" content="Event Image">
</head>
<body>
</body>

</html>

Last week this logic is working fine on Linkedin but now somehow it's not working.

来源:https://stackoverflow.com/questions/42251479/linkedin-open-graph-sharing-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!