Create a Contact with Google Contacts API 3

I am having problems creating a contact record using the Google Contacts API. I am using PHP for this. My problem is that I can create an entry in users contacts, but there is no set of names. The only field that needs to be set is the email address. For example, this is the XML I'm sending:

<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
  <gd:name>
    <gd:givenName>John</gd:givenName>
    <gd:familyName>Smith</gd:familyName>
    <gd:fullName>John Smith</gd:fullName>
  </gd:name>
  <gd:email address="john@smith.com" rel="http://schemas.google.com/g/2005#home"/>
</atom:entry>

      

And here's what comes back:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:batch="http://schemas.google.com/gdata/batch" xmlns:gContact="http://schemas.google.com/contact/2008" xmlns:gd="http://schemas.google.com/g/2005">
<id>http://www.google.com/m8/feeds/contacts/user@domain/base/xyz123</id>
<updated>2015-05-13T08:30:56.531Z</updated>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<title type="text"/>
<link rel="http://schemas.google.com/contacts/2008/rel#edit-photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/user@domain/xyz123/abc987"/>
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/user@domain/xyz123"/>
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/user@domain/xyz123/1431505856531001"/>
<gd:email rel="http://schemas.google.com/g/2005#home" address="john@smith.com"/>
</entry>

      

Note that "title" is empty when returned:

<title type="text"/>

      

What am I missing?

Edit

To summarize - I can create a contact record. I have set the givenName, familyName, fullName and email to the XML I message as shown in the first block of code. The contact was successfully created, but only the email is saved. GivenName, FamilyName and FullName are not set. The desired behavior would be to create a contact that contains a givenName, familyName, fullName and email.

solved

To set the title, you must add an xml element:

<atom:title>John Smith</atom:title>

      

I mistakenly assumed that the given name and surname name_Name and fullName were given a title. So my original XML request would look like this:

<?xml version="1.0"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
  <atom:title>John Smith</atom:title>
  <gd:name>
    <gd:givenName>John</gd:givenName>
    <gd:familyName>Smith</gd:familyName>
    <gd:fullName>John Smith</gd:fullName>
  </gd:name>
  <gd:email address="john@smith.com" rel="http://schemas.google.com/g/2005#home"/>
</atom:entry>

      

+3
xml php google-api-php-client google-contacts


source to share


No one has answered this question yet

Check out similar questions:

2263
How to get YouTube video thumbnail using YouTube API?
6
Creating an XSL feed for Atom
3
Google contacts api (gdata) syncs low resolution photos
3
XML parsing with Python ElementTree with wrong tags
2
How do I create a google contact in the All Contacts group using the google contacts v3 API?
1
Unable to parse rss feed
0
Golang: xml unmarshall not working as expected
0
RESTful API Calls and XML Parsing
0
401 Unauthorized error while trying to create a shared contact with Google App
0
Google Slow Contacts API



All Articles
Loading...
X
Show
Funny
Dev
Pics