首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Contacts API错误

Google Contacts API错误
EN

Stack Overflow用户
提问于 2012-08-02 14:29:28
回答 2查看 1.4K关注 0票数 2

我使用下面的代码来获取google联系人的姓名和电话号码。授权页面本身不能正常显示错误,因为“您请求的页面无效”。:(请帮我解决这个问题...

`

代码语言:javascript
复制
<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>`

谢谢

EN

回答 2

Stack Overflow用户

发布于 2012-08-03 11:35:32

看起来您正在尝试使用Google Contacts 1.X API。这已经被弃用了。查看JavaScript examples for the Google 3.X API,看看这是否有帮助。

票数 1
EN

Stack Overflow用户

发布于 2017-01-10 18:21:52

你可以试试这个例子

代码语言:javascript
复制
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文件中。祝好运!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11772166

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档