我正在尝试在“我的联系人”系统组中添加联系人。通过Google Contacts API在正确的系统组中添加联系人
我能创造一个接触“而不群”(保存在“其他联系人”) 看到代码:http://pastebin.com/q0zksgM7
{
$acontact_formated = '
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<gd:name>
<gd:givenName>'.$acontact["givenName"].'</gd:givenName>
<gd:familyName>'.$acontact["sn"].'</gd:familyName>
<gd:fullName>'.$acontact["displayName"].'</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work" primary="true" address="'.$acontact["mail"].'" displayName="'.$acontact["displayName"].'" />
</atom:entry>';
$urlToSendReq = "https://www.google.com/m8/feeds/contacts/".$this->_account."/full/?access_token=".$this->_access_token;
$bodyRequest = $acontact_formated;
$headerRequest = array("Content-Type"=>"application/atom+xml", "GData-Version"=>"3.0");
try
{return myhttpservice::httpPost($urlToSendReq, $headerRequest, $bodyRequest);}
catch (GuzzleHttp\Exception\ClientException $e)
{return $e->getMessage();}
return "OK";
}
但是当我接触创造的ATOM添加任何“组ID”,我得到一个“错误的请求”: 看到前面的代码修改:http://pastebin.com/gUCTs1K7
{
$acontact_formated = '
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<gd:name>
<gd:givenName>'.$acontact["givenName"].'</gd:givenName>
<gd:familyName>'.$acontact["sn"].'</gd:familyName>
<gd:fullName>'.$acontact["displayName"].'</gd:fullName>
</gd:name>
<gd:email rel="http://schemas.google.com/g/2005#work" primary="true" address="'.$acontact["mail"].'" displayName="'.$acontact["displayName"].'" />
<gContact:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/'.$this->_account.'/base/'.$this->MySystemContactGroupId.'"/>
</atom:entry>';
$urlToSendReq = "https://www.google.com/m8/feeds/contacts/".$this->_account."/full/?access_token=".$this->_access_token;
$bodyRequest = $acontact_formated;
$headerRequest = array("Content-Type"=>"application/atom+xml", "GData-Version"=>"3.0");
try
{return myhttpservice::httpPost($urlToSendReq, $headerRequest, $bodyRequest);}
catch (GuzzleHttp\Exception\ClientException $e)
{return $e->getMessage();}
return "OK";
}
是否有可能直接在“我的联系人”系统组创建一个联系人,或者是否有必要在第1时间t创建他之后联系并更新?
感谢您的帮助:)