使用php-ews向Exchange 2007添加约会

Kei*_*ith 1 php exchange-server exchangewebservices

有没有人有任何php-ews的经验?我想通过php-ews添加一个新的约会到Exchange 2007日历,但我不知道如何.php-ews的文档非常有限.有没有人以前做过这件事,并提供和示例?谢谢

tes*_*ssr 6

啊.几个星期前我经历过这个.文档很糟糕.如果您对PHP和EWS有任何疑问,请随时与我联系.

因此,假设您要为某些用户的日历创建新的日历事件,则需要首先下载James Armes的Exchange Web服务客户端:http://code.google.com/p/php-ews/source/browse/

它是一系列PHP类,可以通过PHP轻松访问Exchange服务器.

然后,您创建一个ExchangeWebServices对象

$ews = new ExchangeWebServices(
'server address',
'username@address',
'password'
);
Run Code Online (Sandbox Code Playgroud)

从那里,您可以通过在PHP中构造"请求"对象来构造SOAP XML请求,其中对象的属性是SOAP请求的层.

    $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;
Run Code Online (Sandbox Code Playgroud)

然后将请求发送到服务器:

    $response = $ews->CreateItem($request);
Run Code Online (Sandbox Code Playgroud)

var_dump-ing $ response将为您提供服务器响应,并让您对XML的工作原理有所了解.

至于什么是小文档,Microsoft文档将告诉您如何设置XML请求(即,给出哪些对象的属性)以及您可以调用XML请求的方法:http://msdn.microsoft .com/zh-cn/library/bb204119(v = exchg.140).aspx(参见"操作"和"XML元素")

希望这可以帮助!如果您有任何疑问,请告诉我.