Comments (5)
Hi. I change function create. So you can create multiple phone type and multiple email
$phoneNumber, $emailAddress - must be arrays
public static function create($name, $phoneNumber, $emailAddress)
{
$doc = new \DOMDocument();
$doc->formatOutput = true;
$entry = $doc->createElement('atom:entry');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
$entry->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
$doc->appendChild($entry);
$title = $doc->createElement('title', $name);
$entry->appendChild($title);
foreach($emailAddress as $key=>$one_mail){
$email = $doc->createElement('gd:email');
if(!$key){
$email->setAttribute('primary', 'true');
}
$email->setAttribute('rel','http://schemas.google.com/g/2005#work');
$email->setAttribute('address',$one_mail);
$entry->appendChild($email);
}
foreach($phoneNumber as $key=>$phone){
$contact = $doc->createElement('gd:phoneNumber', $phone);
if(!$key){
$contact->setAttribute('primary', 'true');
}
$contact->setAttribute('rel', 'http://schemas.google.com/g/2005#work');
$entry->appendChild($contact);
}
$xmlToSend = $doc->saveXML();
$client = GoogleHelper::getClient();
$req = new \Google_Http_Request('https://www.google.com/m8/feeds/contacts/default/full');
$req->setRequestHeaders(array('content-type' => 'application/atom+xml; charset=UTF-8; type=feed'));
$req->setRequestMethod('POST');
$req->setPostBody($xmlToSend);
$val = $client->getAuth()->authenticatedRequest($req);
$response = $val->getResponseBody();
$xmlContact = simplexml_load_string($response);
$xmlContact->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
$xmlContactsEntry = $xmlContact;
$contactDetails = array();
$contactDetails['id'] = (string) $xmlContactsEntry->id;
$contactDetails['name'] = (string) $xmlContactsEntry->title;
foreach ($xmlContactsEntry->children() as $key => $value) {
$attributes = $value->attributes();
if ($key == 'link') {
if ($attributes['rel'] == 'edit') {
$contactDetails['editURL'] = (string) $attributes['href'];
} elseif ($attributes['rel'] == 'self') {
$contactDetails['selfURL'] = (string) $attributes['href'];
}
}
}
$contactGDNodes = $xmlContactsEntry->children('http://schemas.google.com/g/2005');
foreach ($contactGDNodes as $key => $value) {
$attributes = $value->attributes();
if ($key == 'email') {
$contactDetails[$key] = (string) $attributes['address'];
} else {
$contactDetails[$key] = (string) $value;
}
}
return new Contact($contactDetails);
}
from php-google-contacts-v3-api.
It looks like we'll be able to change http://schemas.google.com/g/2005#work
to http://schemas.google.com/g/2005#home
or http://schemas.google.com/g/2005#other
in order to submit multiple different types of phone numbers or email addresses.
from php-google-contacts-v3-api.
Ok. Can you solve a problem with update multiple count?
from php-google-contacts-v3-api.
I have a similar question related to this. Is there a possible solution for updating multiple emails? ie. #45
from php-google-contacts-v3-api.
Unfortunately, this library can't handle multiple email addresses, telephone numbers, etc.
We've recently written a new package, PHP Google People API, that uses an improved API to access Google Contacts information. This library is very capable of retrieving and updating multiple emails address, telephone numbers and so on.
from php-google-contacts-v3-api.
Related Issues (20)
- Duplicated new contacts HOT 1
- Does the submitUpdates method allow for a contact object with multiple email addresses? HOT 1
- Error running authorise-application.php, is currently unable to handle this request. HTTP ERROR 500 HOT 2
- Logical Error while editing content in contact
- authorization link crashed HOT 5
- how to get selfURL ? HOT 2
- Delete contact from my account HOT 1
- simplexml_load_string(): Entity: line 7: parser error : Opening and ending tag mismatch: meta line 1 and head HOT 2
- Can't set the prefix name for Contact HOT 1
- Delete all contacts HOT 1
- Can't access many attributes ! HOT 1
- Full rewrite to use Google People API HOT 1
- Error 400 authorise-application.php generated link HOT 3
- How do you delete a contact HOT 1
- Use google contacts for sync in app
- Problem with device synchronization
- Title not coming during create Contact HOT 3
- ContactFactory::getBySelfURL don't valid response
- Missing Contact Name After Update Contact HOT 3
- How create a birthday date and a link to website ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-google-contacts-v3-api.