![](/img/trans.png)
[英]Facebook-Share with open graph custom Title, Image, Description not showing (Magento 2)
[英]Facebook share not showing image from open graph metatags
我正在嘗試將Facebook共享按鈕集成到我的雇主的網站,標題,網址,說明/介紹都正確顯示,但沒有附加圖像。 當共享對話框打開時,圖像容器會閃爍然后消失,就像facebook正在嘗試處理圖像但失敗一樣。
我正在使用og:image和鏈接關系來嘗試指定用於共享鏈接的圖像:
<meta property="og:image" content="/images/logo_white_150px.png" />
<link rel="image_src" type="image/png" href="/images/logo_white_150px.png" />
該圖像曾經工作(它適當縮放)但不再適用,我也嘗試過其他不同尺寸和格式的圖像而沒有運氣。
這是我在標題中使用的開放元標記:
<!DOCTYPE html>
<html xmlns:fb="http://ogp.me/ns/fb#" itemscope itemtype="http://schema.org/Article" xmlns:og="http://ogp.me/ns#">
<head>
<meta property="og:type" content="landing page" />
<meta property="og:title" content="Social Media Test Page" />
<meta property="og:description" content="This is a page for testing the behavior of social media buttons..." />
<meta property="og:image" content="/images/logo_white_150px.png" />
<link rel="image_src" type="image/png" href="/images/logo_white_150px.png" />
<meta property="og:image:type" content="image/png" />
<meta property="og:url" content="<%=shortUrl%>" />
<meta property="og:site_name" content="site name" />
<meta property="og:medium" content="mult" />
</head>
這是我在身體開始時使用的JavaScript:
<body>
<script type="text/javascript">
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
</script>
...
以下是我使用按鈕的方式:
<div class="left" style="text-align: center;">
<a name="fb_share" type="button" share_url="<%=shortUrl%>">Share</a>
<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
</div>
非常感謝任何幫助,在此先感謝
克里斯。
如果刪除的結果一切正常,請嘗試使用Facebook調試器獲取新的剪貼信息。
這是因為Facebook為og:data使用自己的緩存。
在我的經驗中 :
對於主要網址重定向非常棘手,您應該確保內容正確(並且完全)獲取,對於復雜的動態內容,我經常最終在.htaccess中進行檢測,以便為FB的抓取工具提供適當的內容,如下所示:
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} facebookexternalhit/[0-9]
RewriteRule ^(.*)$ OG_GENERATOR_SCRIPT_HERE.php [L,QSA]
如果沒有看到代碼中的HTML輸出,我只能猜測問題。 不要使用像<%=shortUrl%>
這樣的相對URL,但一定要使用完全合格的Url ....上面有http(s)://的東西。
此外, http : //developers.facebook.com/docs/share/表示此共享按鈕已被棄用。 請轉而使用Like按鈕: http : //developers.facebook.com/docs/reference/plugins/like/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.