google contacts api not adding name and address in google contact

*爱你&永不变心* 提交于 2019-12-08 05:32:01

问题


we are sending xml through curl in cakephp, but only email and phone numbers are adding in
google contacts , other fields are blank,can we get proper xml to add all fields in google contacts through api our xml code:

 $xml = <<<'EOF'
 <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'/>

   <title type="text">TITLE</title>
  <gd:name>
 <gd:givenName>First</gd:givenName>
 <gd:additionalName>ADDITIONALNAME</gd:additionalName>
 <gd:familyName>Last</gd:familyName>
 <gd:namePrefix>NAMEPREFIX</gd:namePrefix>
 <gd:nameSuffix>NAMESUFFIX</gd:nameSuffix>
  </gd:name>
 <gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>
 <gd:city>CITY</gd:city>
 <gd:street>STREET</gd:street>
 <gd:region>REGION</gd:region>
<gd:postcode>POSTCODE</gd:postcode>
<gd:country>COUNTRY</gd:country>
 </gd:structuredPostalAddress>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home' primary='true'>
  HOMEPHONENUMBER
</gd:phoneNumber>\
<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>MOBILENO</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work'>WORKPHONENO</gd:phoneNumber>
<gd:email label="home" address="EMAILADDRESS" displayName="DISPLAYNAME" />
</atom:entry>
EOF;

回答1:


We need to add this header gdata-version: 3.0 along with the Authorization header to the post call. This answer is already here




回答2:


now this xml is working

$xml = <<<'EOF'
<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'/>

 <atom:title>Full Name</atom:title>

<gd:name>
<gd:givenName>CODE1</gd:givenName>
<gd:familyName>Last</gd:familyName>
<gd:fullName>My Name</gd:fullName>

</gd:name>

<gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>
<gd:city>CITY</gd:city>
<gd:street>STREET</gd:street>
<gd:region>REGION</gd:region>
<gd:postcode>POSTCODE</gd:postcode>
<gd:country>COUNTRY</gd:country>

</gd:structuredPostalAddress>

 <gd:phoneNumber rel='http://schemas.google.com/g/2005#home' primary='true'>
 HOMEPHONENUMBER

</gd:phoneNumber>

<gd:phoneNumber rel='http://schemas.google.com/g/2005#mobile'>MOBILENO</gd:phoneNumber>

<gd:phoneNumber rel='http://schemas.google.com/g/2005#work'>WORKPHONENO</gd:phoneNumber>

<gd:email label="home" address="EMAILADDRESS" displayName="DISPLAYNAME" />

 EOF;


来源:https://stackoverflow.com/questions/20761210/google-contacts-api-not-adding-name-and-address-in-google-contact

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!