0

I want to add a contact with data to google contacts.i am getting error as "There was an error in your request. That's all we know."

The code is as follows

<?php
$contact_detail='<?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:firstName>John</gd:firstName>
        <gd:additionalName> test</gd:additionalName>
        <gd:givenName>Doe</gd:givenName>
    </gd:name>
    <gd:email address="john@doe.com" rel="http://schemas.google.com/g/2005#work"/>
    <gd:email address="john2@doe.com" rel="http://schemas.google.com/g/2005#home"/>
    <gd:organization rel="http://schemas.google.com/g/2005#work">
        <gd:orgName>John Deere</gd:orgName>
        <gd:orgTitle>Owner</gd:orgTitle>
    </gd:organization>
</atom:entry>';
$url="https://www.google.com/m8/feeds/contacts/default/full";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$contact_detail");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
print($output);
curl_close($ch);
Kara
  • 6,115
  • 16
  • 50
  • 57
Nitin
  • 1
  • 1
  • 6

1 Answers1

0

https://developers.google.com/google-apps/contacts/v2/developers_guide_protocol

To publish this entry, send it to the contact-list post URL as follows. First, place your Atom element in the body of a new POST request, using the application/atom+xml content type. Then send it to the post URL. For example, to add a contact to the contact list belonging to liz@gmail.com, post the new entry to the following URL: https://www.google.com/m8/feeds/contacts/liz%40gmail.com/full

realization
  • 587
  • 1
  • 4
  • 5