Google Contact API, creating of new group

can u tell me what I'm doing wrong? Still getting 'GData invalid Entry does not have any fields set' when I'm trying to create new contact group... I have tried almost everything. Thank you!

                $url = 'https://www.google.com/m8/feeds/groups/default/full';
                $xml =
                '<?xml version="1.0" encoding="UTF-8"?>
                <atom:entry 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#group"/>
                  <atom:title type="text">Salsa group</atom:title>
                  <gd:extendedProperty name="more info about the group">
                    <info>Nice people.</info>
                  </gd:extendedProperty>
                </atom:entry>
                ';

                $headers = array(
                    'Host: www.google.com',
                    'Gdata-version: 3.0',
                    'Content-length: '.strlen($xml),
                    'Content-type: application/atom+xml; charset=UTF-8; type=entry',
                    'Authorization: OAuth '.$accesstoken
                );

                $xmlresponse =  $this->curl($url, $xml, $headers);

                echo $xmlresponse; exit;

Upvotes: 0

Views: 358

Answers (3)

lyesAlgerian
lyesAlgerian

Reputation: 11

I followed the same xml structure used for adding a new contact and it worked for me . here is the xml structure :

$xml = '<?xml version="1.0" encoding="utf-8"?> '
.'<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#group"/>'
.'<atom:title type="text">Salsa group</atom:title>'
.'<gd:extendedProperty name="more info about the group">'
.'<info>Nice people.</info>'
.'</gd:extendedProperty>'
.'</atom:entry>';

please notice the added

<?xml version="1.0" encoding="utf-8"?> '
.'<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"

Upvotes: 1

air4x
air4x

Reputation: 5683

Faced the same issue. Got it working by using the below as the root tag

<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005">

Note the extra attribute added - xmlns:atom="http://www.w3.org/2005/Atom"

Upvotes: 3

miturbe
miturbe

Reputation: 715

From what the documentation states, you did nothing wrong. I did get it to work using Batch URL with this XML

 <feed xmlns='http://www.w3.org/2005/Atom'
      xmlns:gContact='http://schemas.google.com/contact/2008'
      xmlns:gd='http://schemas.google.com/g/2005'
      xmlns:batch='http://schemas.google.com/gdata/batch'>
  <entry>
    <batch:id>create</batch:id>
    <batch:operation type='insert'/>
    <atom:category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/contact/2008#group'/>

  <title type='text'>CG-Clientes</title>

  <gd:extendedProperty name='Just a test'>
    <info>DO NOT DELETE</info>
  </gd:extendedProperty>
  </entry>
</feed> 

(notice I replaced <atom:title> with just <title>,
this change works in batch but does not work in regular mode)

to the URL https://www.google.com/m8/feeds/groups/default/full/batch

Hope this helps...

Upvotes: 0

Related Questions