Adding an appointment to Exchange 2007 with php-ews
Does anyone have any experience wi开发者_运维知识库th php-ews? I would like to add a new appointment to an Exchange 2007 calendar through php-ews but I'm not sure how. The documentation for php-ews is very limited. Has anyone done this before and care to provide and example? Thanks
Ugh. I went through this a few weeks ago. Documentation for this sucks. Feel free to ask me any questions about PHP and EWS.
So assuming you mean you want to create a new Calendar event for some user's calendar, you need to begin by downloading James Armes's Exchange Web Services client: http://code.google.com/p/php-ews/source/browse/
It's a series of PHP classes which make it easy to access an Exchange server through PHP.
You then create an ExchangeWebServices object
$ews = new ExchangeWebServices(
'server address',
'username@address',
'password'
);
From there you can construct SOAP XML requests by constructing a "request" object in PHP where the attributes of the object are the layers of the SOAP request.
$request->SendMeetingInvitations = 'SendToNone';
$request->SavedItemFolderId->DistinguishedFolderId->Id = 'calendar';
$request->Items->CalendarItem->Subject = 'this is the subject of the email';
$request->Items->CalendarItem->Start = date('c', strtotime('today'));
//making this an all day event for the heck of it
$request->Items->CalendarItem->End = date('c', strtotime('today + 1 day'));
$request->Items->CalendarItem->IsAllDayEvent = true;
$request->Items->CalendarItem->LegacyFreeBusyStatus = 'Free';
$request->Items->CalendarItem->Categories->String = $category;
$request->Items->CalendarItem->Body->BodyType = 'Text';
$request->Items->CalendarItem->Body->_ = $body;
And then you send the request to the server:
$response = $ews->CreateItem($request);
var_dump-ing $response will give you the server response and give you a good idea of how the XML works.
As for what little documentation there is, the Microsoft docs will tell you how the XML requests are set up (i.e., what attributes to give which objects) and also which methods you can call on your XML requests: http://msdn.microsoft.com/en-us/library/bb204119(v=exchg.140).aspx (see "Operations" and "XML Elements")
Hope this helps! Let me know if you have any questions.
精彩评论