Я пытаюсь добавить контакты в системную группу «Мои контакты».Добавить контакт в правильную системную группу с API контактов Google
я могу создать контакт «без группы» (хранится в «Другие контакты») см код: 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 создания контакта, Я получаю «Bad запрос»: см предыдущий код с модификацией: 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-й раз т он контактирует и обновляется после этого?
Спасибо за вашу помощь :)