i'm developing an application in PHP, that needs to upload 100 contacts the first time, i have developed a basic app, to upload a contact, but it takes near to 1,5 seconds to process the request:
$before = microtime(true);
$req = new Google_Http_Request("https://google.com/m8/feeds/contacts/" . $user_email . "/full/");
$req->setRequestMethod("POST");
$req->setPostBody($contact_xml);
$req->setRequestHeaders(array('content-length' => strlen($contact_xml), 'GData-Version' => '3.0', 'content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
$submit = $this->_gclient->getAuth()->authenticatedRequest($req);
$sub_response = $submit->getResponseBody();
$parsed = simplexml_load_string($sub_response);
$client_id = explode("base/", $parsed->id);
//Profiling
$after = microtime(true);
I have tried to contcatenate to my entry twice or the times i needed but it doesn't work:
$contact_xml.="
<atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:gContact='http://schemas.google.com/contact/2008'>
<atom:category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact'/>
...
<gContact:groupMembershipInfo deleted='false'
href='http://www.google.com/m8/feeds/groups/".$user_email."/base/6'/>
</atom:entry>
And the only thing i get from google is:
[1] => SimpleXMLElement Object
(
[error] => SimpleXMLElement Object
(
[domain] => GData
[code] => parseError
[internalReason] => Parse Error
)
)
Which is like ...
- Am i doing something wrong, does Google give any kind of asyncronous request?
- Is even possible to do a multiple upload of google contact entry?
- If i make a loop with the individual upload function it takes too long for an amount of 100 contacts, that's the reason of the question.
Than you!