Comments (3)
Oh, and just FYI, because this is probably what's going to come up at some point next and I may as well let you know now. You're going to have to perform updates manually as well. Unlike creates however, you can't just update with an object. However, you can build an update out of an array. For example, here is how I update calendar items. here is the function that takes an array of Key=>Value objects and turns them in to the fieldUri things you want. So updating a contact will probably look something like this
$changes = array('GivenName' => 'Jane', 'CompleteName' => 'Jane Smith');
//Create the request
$request = array(
'ItemChange' => array(
'ItemId' => $itemId->toArray(),
'Updates' => array(
'SetItemField' => $this->buildUpdateItemChanges('ContactItem', 'contact', $changes)
)
)
);
$items = $this->updateItems($request);
Also, take note of the $itemId->toArray()
, it'll save you from having to do something like 'ItemId' => array('Id' => $itemId->getId(), 'ChangeKey' => $itemId->getChangeKey())
Also, so you have an Id and ChangeKey, and you want to turn that in to an ItemIdType
, you can do so like this $itemId = new ItemIdType($id, $changeKey);
Finally, if you want to see any more examples of how to do things, take a look in Calendar and Mail API's. They interact with the base API in much the same way you'll have to with ContactAPI.
Though I do plan on improving ContactAPI in the coming weeks.
from php-ews.
Yeah, all that? That's why I wrote this instead. Rather than doing that, we can work with arrays. I haven't gotten around to making creating a contact simple yet, so you'll have to create it manually. Here's the Microsoft documentation on creating a contact. If you scroll down a bit, you can see the XML needed, so we'll try to match it with an array. It should look something like this
$result = $ews->createItems(array (
'Contact' => array(
'GivenName' => 'John',
'Surname' => 'Smith',
'Initials' => 'J S',
'CompleteName' => 'John Smith',
'EmailAddress' => array(
'Entry' => array ('Key'=>'EmailAddress1', '_value' => '[email protected]')
)
)
));
And so on. You can pretty much just build your request directly in array's this way. Alternatively, you can create a Type\ContactItemType
object and pass that in. Like this
$contact = new Type\ContactItemType();
$contact->setGivenName('John')
->setSurname('Smith')
->setInitials('J S')
->addEmailAddress(Type\EmailAddressDictionaryType::buildFromArray(array('key' => 'EmailAddress1', '_value' => '[email protected]')))
$result = $ews->createItems(array('Contact' => $contact));
The second should work, but it's also untested. If you go for the second, you can take a look at the file for ContactType to see what you need to pass in for each value.
Just an FYI, I won't be available tomorrow, so if I probably won't be able to answer any more questions till Monday
from php-ews.
Just an FYI, my examples were a bit off (You can't set Initials or CompleteName when creating a contact, those are set automatically. Also, updating EmailAddress is a bit of a special case), but I've now released 0.7.5
which makes it a bit easier, I've also added those examples that you were after. If you have any further issues, please feel free to either add a new issue or just respond to this one
from php-ews.
Related Issues (20)
- Upgrade from jamesiarmes -> garethp php-ews HOT 1
- Create a contact
- internetMessageHeaders HOT 1
- BUG FreeBusyResponse array HOT 1
- toRecipients getting null values for inplace archive mails
- Update Mail Item -> Categorize Email HOT 1
- PHP 8.2 - Deprecated dynamic properties HOT 5
- Oauth is not working with Exchange 2013
- Issue with using toRecipients property in EWS restriction HOT 2
- Daylight Savings
- How to get medias appointment
- Update contact with ExtendedProperty
- Exceptions
- Set a calendar event with custom identifier, so that I can (later on) GET an event by the same identifier HOT 3
- Change "busy" status for event. HOT 2
- Checking if an item exists (by $itemId and $changeKey) results in FATAL ERROR if the object is not found - How to handle this? HOT 1
- Also delete recurring events when master event is deleted? HOT 1
- getLegacyFreeBusyStatus() does not return WorkingElsewhere HOT 1
- Authentication error after Exchange Extended Protection was enabled HOT 2
- Add Kerberos support
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-ews.