【问题标题】:Google Contacts API Not Returning System GroupsGoogle Contacts API 不返回系统组
【发布时间】:2011-08-27 11:03:20
【问题描述】:
https://www.google.com/m8/feeds/groups/default/full/6

这应该返回系统组“我的联系人”中所有联系人的列表,但它显示“未找到组”。

当我请求所有联系人组的列表时,它只返回用户定义的组。

当我请求我的所有联系人列表时,它会提供我所有的联系人,但它不会告诉我他们在哪个组中,除非它是用户定义的组。

关于我做错了什么有什么想法吗?

编辑: 我在这里重定向

https://accounts.google.com/o/oauth2/auth?client_id=819467938951.apps.googleusercontent.com&redirect_uri=http://subomain.website.com/back.html&scope=https://www.google.com/m8/feeds/&response_type=code

这是back.html的来源(修改自http://php.dzone.com/news/execute-http-post-using-php-cu

<?php
$token = $_GET["code"];

$url = 'https://accounts.google.com/o/oauth2/token';
$fields = array(
        'code'=>urlencode($token),
        'client_id'=>urlencode("819467938951.apps.googleusercontent.com"),
        'client_secret'=>urlencode("secret key"),
        'redirect_uri'=>urlencode("http://subdomain.website.com/back.html"),
        'grant_type'=>urlencode("authorization_code")
    );

//url-ify the data for the POST
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

$result=json_decode($result, true);

$access_token = $result["access_token"];

print_r(file_get_contents("https://www.google.com/m8/feeds/groups/default/full/6?access_token=" . $access_token));
?>

【问题讨论】:

  • 你做错的一件事是你没有给我们使用的代码;)

标签: php android-contacts google-contacts-api


【解决方案1】:

retrieve all contacts from a group in PHP

一旦我设置了 v=2,系统组终于出现了!

https://www.google.com/m8/feeds/groups/default/full?v=2

要获取组中的联系人,请设置 group = group url

https://www.google.com/m8/feeds/contacts/default/full?v=2&group=http://www.google.com/m8/feeds/groups/default/base/6

【讨论】:

  • 或者,您可以将标头GData-Version 设置为大于或等于2.0 的某个值,例如:GData-Version: 3.0
猜你喜欢
  • 2014-08-16
  • 1970-01-01
  • 2014-09-13
  • 1970-01-01
  • 2013-01-15
  • 2019-06-25
  • 2013-12-22
  • 1970-01-01
  • 2016-10-18
相关资源
最近更新 更多