2014-08-31 69 views
1

我正在嘗試在我的網站上使用Google+分享。我正在使用一個錨標籤。Google+分享未填充圖片,標題,說明

<a target="_blank" id="btnGoogleShare" href="#" runat="server"> 
Google+</a> 

在後面的代碼我設置HREF作爲

btnGoogleShare.Href = "https://plus.google.com/share?url=[My site url]/page?_i=10" 

我添加

<script type="text/javascript" src="https://apis.google.com/js/plusone.js"> 
</script> 
<meta itemprop="name" content="Sample Title"> 
<meta itemprop="description" content="Sample Description"> 
<meta itemprop="image" content="[My site url]/SampleImage.jpg"> 
<meta property="og:type" content="website"> 
<meta property="og:url" content="https://plus.google.com/share?url=https://plus.google.com/share?url=http//:MySite.com/page?_i=10> 
<meta property="og:title" content="Sample Title"> 
<meta property="og:description" content="Sample Description"> 
<meta property="og:image" content="[my site URL]/SampleImage.jpg"> 

我正在我的網站在本地主機在Visual Studio繼頭標記標籤。當我點擊鏈接時,我只能在谷歌加分享對話框中獲得網址。標題,說明,圖像沒有填充。任何想法?這可能是因爲我在使用本地主機的Visual Studio中的開發環境中運行?

回答

1

我在visual studio中的本地主機上運行我的網站。

Google+通過提取頁面並通過Google服務器解析詳細信息來填充該字段。如果網址不在網絡上公開訪問,那麼Google+分享功能只會顯示該網址。

+0

謝謝亞伯拉罕,我沒有意識到這件事。所以這意味着如果我將更改部署到服務器,那麼它會自動選擇所有正確的信息,或者我需要做任何其他的事情。我寫的代碼可以嗎?如果需要更改,請提出建議。 – Deepak 2014-09-01 07:03:01

+0

只要你按照[文檔](https://developers.google.com/+/web/snippet/)你應該沒問題。部署更新後,可以使用[結構化數據工具](https://www.google.com/webmasters/tools/richsnippets)對其進行測試。 – abraham 2014-09-01 08:50:06