2012-08-13 13 views
5

私は、顧客のGmail情報をインポートするために、Gdataライブラリ付きのContacts API 2.0バージョンを使用しました。このバージョンはもはやサポートされておらず、V3に移行しようとしていますが、v3でサポートされていないGdataが表示され、現在のコードを変更して「連絡先APIバージョン3.0」をjavascript用に使用しています。google-api-javascript-clientまたは「Contacts API version 3.0」を使用してGmailから連絡先をインポートするにはどうすればよいですか?

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title>Gmail Login</title> 
     <meta http-equiv="content-type" content="text/html;charset=UTF-8"/> 
     <script type="text/javascript" src="http://www.google.com/jsapi"></script> 
    </head> 
    <body style="margin:0;padding:0;"> 
     <img src="/images/templates.png" style="display:none;"/> 
     <script type="text/javascript"> 
      google.load("gdata", "2.s"); 
      google.setOnLoadCallback(function(){ 
       if(window.location.hash=="") { 
        if(!checkLogin()){ 
         logMeIn(); 
        } else { 
         var feedUrl = "https://www.google.com/m8/feeds/contacts/default/full"; 
         query = new google.gdata.contacts.ContactQuery(feedUrl); 
         query.setMaxResults(5000); 
         myService = new google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0'); 
         myService.getContactFeed(query, function(result) { 
           document.cookie="g314-scope-0="; 
            window.opener.parseGmailContacts(result.feed.entry); 
          close(); 
          }, function(e){ 
           alert(e.cause ? e.cause.statusText : e.message); 
         }); 
        } 
       } 
      }); 
      function logMeIn() { 
       scope = "https://www.google.com/m8/feeds"; 
       var token = google.accounts.user.login(scope); 
      } 
      function logMeOut() { 
       google.accounts.user.logout(); 
      } 
      function checkLogin(){ 
       scope = "https://www.google.com/m8/feeds/"; 
       var token = google.accounts.user.checkLogin(scope); 
       return token; 
      } 
     </script> 
    </body> 
    </html> 

GoogleコンタクトAPIバージョン3.0は、javascriptクライアントまたはgdataライブラリをサポートしていますか?

答えて

7
var authParams = gapi.auth.getToken() // from Google oAuth 

authParams.alt = 'json'; 

$.ajax({ 
    url: 'https://www.google.com/m8/feeds/contacts/default/full', 
    dataType: 'jsonp', 
    data: authParams, 
    success: function(data) { console.log(data); } 
}); 

は、基本的にはちょうどGoogleのAPI JavaScriptライブラリで提供さauthSample.htmlにこのプラグ - https://code.google.com/p/google-api-javascript-client/

+0

をこの質問に答えるいただきありがとうございますが、私はGAPIライブラリを読んで、それ以上右サポートし、私は持っていませんエラーは私に関連するJSライブラリを含めるが、gapiは未定義であることを教えてください –

関連する問題