2013-03-02 79 views
0

我想爲我的博客添加Google徽章。目前,我加入了谷歌加徽章到我的博客,並試圖通過下面的代碼將圖像添加到它:將頭像添加到Google加徽章的最佳方式是什麼?

<div class="g-plus" data-width="208" data-height="69" style="float:left; direction:ltr;text-align:left" data-href="//plus.google.com/116527224364668694256" data-rel="author"></div> 

<script type="text/javascript"> 
    (function() { 
    var po = document.createElement('script'); 
    po.type = 'text/javascript'; 
    po.async = true; 
    po.src = 'https://apis.google.com/js/plusone.js'; 
    var s = document.getElementsByTagName('script')[0]; 
    s.parentNode.insertBefore(po, s); 
    var iab = document.getElementsByClassName("iab")[0]; 
    iab.style.backgroundimage = "url('https://googledrive.com/host/0B7YvaD77pFw9cDczZnBRanFFVWs/img/avatar.jpg')"; 
    })(); 
</script> 

和輸出是這樣的:
My Google+ badge

我想加上我自己的頭像到它,但它不能正常工作。這段代碼的問題是什麼?最好的方法是什麼?

回答

1

沒有辦法在Google+徽章上顯示您的頭像。這裏的文檔:

https://developers.google.com/+/web/badge/

有什麼可以對徽章進行配置的最新信息。高級選項可讓您設置可顯示更多或更少信息的徽章寬度,但目前沒有顯示頭像的選項。

徽章渲染代碼將覆蓋您已設置的任何樣式,這就是爲什麼您的其他設置不會更改徽章顯示方式的原因。

如果你只是想使你的頭像,你可以使用谷歌API來完成它,如在谷歌API的探險家在這裏:

https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=109716647623830091721&_h=1&

,然後檢索從人對象的個人資料照片這是返回。

相關問題