我正在嘗試在「我的聯繫人」系統組中添加聯繫人。通過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創建他之後聯繫並更新?
感謝您的幫助:)