5

I have a task at hand which requires me to connect Exchange Online account and list all the calendar entries in PHP.

I have read through many Microsoft help doc but it all refers to c# code. Can someone please guide me through steps to achieve this using PHP.

VMN
  • 181
  • 1
  • 2
  • 14

1 Answers1

14

Try this:

$ews = new ExchangeWebServices($host, $username, $password);

$request = new EWSType_FindItemType();
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;

$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape =
        EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;

$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate = date('c', strtotime('01/01/2011 -00'));
$request->CalendarView->EndDate = date('c', strtotime('01/31/2011 -00'));

$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId =
        new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id =
        EWSType_DistinguishedFolderIdNameType::CALENDAR;

With this: https://github.com/jamesiarmes/php-ews

fnkr
  • 9,428
  • 6
  • 54
  • 61
  • We created an account in Office 360 and trying to access the calendar there. Exchange Online Service NOT Exchange 2007 or others. We are trying to connect exchange online account https://portal.microsoftonline.com/. Will we be able to connect online or this code works with local exchange mail server What should be the host name ? We are trying to use vinniehash.onmicrosoft.com Thats was generated when we created the account – VMN Feb 18 '13 at 15:10
  • 1
    Why don't you run the supplied code against your server to find out? – Brian Kelly Feb 19 '13 at 19:55
  • @fnkr did you test it, what did you come up with, did the php-ews library work against your vinniehash.onmicrosoft.com server hosted at microsoftonline? – mikkelbreum Sep 24 '14 at 11:47