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>

出力は次のとおりです。
私の Google+ バッジ

自分のアバターを追加したいのですが、うまくいきません。このコードの問題点と、それを行う最善の方法は何ですか?

4

1 に答える 1

1

Google+ バッジにアバターを表示する方法はありません。ドキュメントはこちら:

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

バッジで構成できるものに関する最新情報があります。高度なオプションを使用すると、表示する情報を増減できるバッジの幅を設定できますが、現在、アバターを表示するオプションはありません。

バッジ レンダリング コードは、設定したすべてのスタイルをオーバーライドします。これが、追加の設定がバッジの表示方法を変更しない理由です。

アバターをレンダリングしたいだけの場合は、Google API Explorer に示されているように、Google API を使用して実行できます。

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

次に、返された人物オブジェクトからプロフィール写真を取得します。

于 2013-03-04T21:44:12.337 に答える