2012-08-02 6 views
2
내가 구글 연락처 이름과 전화 번호를 얻기 위해 다음 코드를 사용하고

. 권한 부여 페이지 자체가 제대로 표시되지 않으면 "요청한 페이지가 유효하지 않습니다"라는 오류가 표시됩니다. :(PLS ... 내가이 문제를 해결하기 위해Google 주소록 API 오류

`

<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
    google.load("gdata", "1.x"); 

    var contactsService; 
    function setupContactsService() 
    { 
    contactsService = new google.gdata.contacts.ContactsService('exampleCo-exampleApp-1.0'); 
    } 
    function logMeIn() { 
     var scope = 'https://www.google.com/m8/feeds'; 
     var token = google.accounts.user.login(scope); 
     } 
    function initFunc() { 
     setupContactsService(); 
     logMeIn(); 
     getMyContacts(); 
     } 
    function checkLoggedIn(){ 
     scope = "https://www.google.com/m8/feeds"; 
     var token = google.accounts.user.checkLogin(scope); 

     if(token != "") 
     return true; 
     else 
     return false; 
     } 
    function getMyContacts() { 
     var contactsFeedUri = 'https://www.google.com/m8/feeds/contacts/default/full'; 

     var query = new google.gdata.contacts.ContactQuery(contactsFeedUri); 

     //We load all results by default// 
     query.setMaxResults(10); 

     contactsService.getContactFeed(query, handleContactsFeed, ContactsServiceInitError); 
     } 
//Gets the contacts feed passed as parameter// 
    var handleContactsFeed = function(result) { 

    //All contact entries// 
    entries = result.feed.entry; 
    for (var i = 0; i < entries.length; i++) { 
     var contactEntry = entries[i]; 
     var telNumbers = contactEntry.getPhoneNumbers(); 
     var title = contactEntry.getTitle().getText(); 
     } 
} 
</script> 
<body> 
<input type="submit" value="Login to Google" id="glogin" onclick="initFunc();"> 
</body>` 

감사

당신이 구글 연락처 1.x에서 API를 사용하려고하는 것 같습니다

답변

1

도움이됩니다. 사용되지 않습니다있어 그. 봐 JavaScript examples for the Google 3.X API하고 도움이되는지 확인합니다.

+0

정말 감사드립니다 :) 늦게 답장을 드려 죄송합니다. –

0

이 예를 시도 할 수 있습니다

var config = { 
    'client_id': 'Client ID', 
    'scope': 'https://www.google.com/m8/feeds' 
}; 

inviteContacts = function() { 
    gapi.auth.authorize($scope.config, function() { 
     fetch(gapi.auth.getToken()); 
    }); 
} 

function fetch(token) { 
    $.get("https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&alt=json", function(response) { 
     console.log(response); 
     //console.log(response.data.feed.entry); 
    }); 
} 

<script src="https://apis.google.com/js/client.js"></script>을 html 파일에 추가하는 것을 잊지 마십시오. 행운을 빕니다!