簡體   English   中英

Google Plus使用動態內容的共享無法正常工作

[英]Google plus share using dynamic content not working

我正在使用車輛跟蹤網站,在這里我必須在Google中共享一些動態內容,並以預填​​充文本的形式共享。 問題是我在google plus中共享的內容是共享的,當我第一次單擊google plus share時,通過ajax一次自動刷新內容一分鍾后,預填充文本內容就會更新,但是我單擊google plus share中的共享按鈕窗口內容不會發布給任何人。

這是示例代碼

<html>
  <head>
    <title>Share Demo: Deferred execution with language code</title>
    <link rel="canonical" href="http://www.example.com" />
  </head>
  <body>
  <script type="text/javascript" src="https://apis.google.com/js/client:plusone.js"></script>
    <div id ="sharePost" action="share">Share</div>
<script>
function add(){
   var options = {
        contenturl: 'https://plus.google.com/pages/',
        contentdeeplinkid: '/pages',
        clientid: 'xxx',
        cookiepolicy: 'single_host_origin',
        prefilltext: 'Hai happy friday'+Math.random(),
        calltoactionlabel: 'CREATE',
        calltoactionurl: 'http://plus.google.com/pages/create',
        calltoactiondeeplinkid: '/pages/create'
      };
      // Call the render method when appropriate within your app to display
      // the button.
      gapi.interactivepost.render('sharePost', options);
}

       setInterval(function(){
         add();
       },2000);

      add();
      </script>
  </body>
</html>

我可以使用Java腳本渲染方法共享交互式帖子。我們需要注意的要點是,我們需要對contenturl和calltoactionurl使用相同的url。

<html>
      <head>
        <title>Share Demo: Deferred execution with language code</title>
        <link rel="canonical" href="http://www.example.com" />
      </head>
      <body>
      <script>
      window.___gcfg = {
                lang: 'en-US',
                parsetags: 'explicit'
              };
      </script>
      <script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
        <div id ="sharePost">Share</div>
     <script>
         (function() {
               var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
               po.src = 'http://apis.google.com/js/client:plusone.js';
               var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
             })();
         var options = {
                    contenturl: 'http://www.google.com',
                    contentdeeplinkid: '/pages',
                    clientid: 'xxxxxxxxxxx.apps.googleusercontent.com',
                    cookiepolicy: 'single_host_origin',
                    prefilltext: 'Hai happy friday',
                    calltoactionlabel: 'INVITE',
                    calltoactionurl: 'http://www.google.com'
                  };
                  // Call the render method when appropriate within your app to display
                  // the button.
                  gapi.interactivepost.render('sharePost', options);

          </script>
      </body>
    </html>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM