Linkedin Open Graph共享无法正常工作 [英] Linkedin Open Graph Sharing not working
问题描述
我有一个用于开放图谱协议的页面设置,因为当我们使用LinkedIn共享URL时,我们的应用程序是基于Angular 1.x构建的. 共享弹出窗口"将打开,但有时不对打开的图形标记进行爬网,有时它会显示正确的爬网标记,直到上周仍能正常工作.这是显示预览区域的图像:
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:
共享链接的场景:
- 用户进入我们的网站:
www.example.com/event/[EVENT_ID]
,然后点击分享到LinkedIn. - 弹出式窗口使用以下命令打开:
https://www.linkedin.com/shareArticle?mini=true&url=https://example.com/event/0u83s43rf6r/4295028179
其中,4295028179
是事件ID,而0u83s43rf6r
是由于缓存无效而用于共享的随机密钥. - 现在我们正在使用apache
mod_rewrite
将LinkedIn,Facebook,Twitter机器人重定向到我们的抓取器页面,在该页面中呈现Open graph标签.
- User comes on our site:
www.example.com/event/[EVENT_ID]
and clicks share to LinkedIn. - Popups opens using:
https://www.linkedin.com/shareArticle?mini=true&url=https://example.com/event/0u83s43rf6r/4295028179
where4295028179
is event id and0u83s43rf6r
is a random key for sharing because of cache busting. - Now we are using apache
mod_rewrite
to redirect LinkedIn, Facebook, Twitter bot to our crawler page where Open graph tags are rendered.
.htaccess
文件中的Apache Mod重写设置
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]
因此,当爬网程序基于呈现打开的图形标记的USER AGENT
进行重定向时,最终网址将变为:http://share.example.com/web/crwaler/details/4295028179
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
以下是呈现的html标签:
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>
上周,此逻辑在Linkedin上运行良好,但现在却不起作用.
Last week this logic is working fine on Linkedin but now somehow it's not working.
推荐答案
您的代码看起来不错,您使用了正确的og:
标签,等等.
Your code seems fine, you have the right og:
tags, etc..
Whenever you're not sure that you're using the LinkedIn share API, check out your website with the LinkedIn Post Inspector, and this will tell you how the LinkedIn API is looking at your webpage. It covers many things, from <title>
tags, to og:
tags, to oEmbed
tags, etc., etc..
担心缓存吗?为什么不测试像example.com?someFakeParameter=123
这样的URL?同样,这将绕过LinkedIn Post Inspector的缓存.
Worried about caching? Why not test a URL like example.com?someFakeParameter=123
? This will similarly bypass the caching at the LinkedIn Post Inspector.
如果您可以发布您要共享的实际URL,我可以为您提供更好的答案,但希望这里有帮助!
If you could post your actual URL that you're sharing, I could give you a better answer, but hopefully something here helps!
这篇关于Linkedin Open Graph共享无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!