Advertisement
Guest User

Untitled

a guest
Nov 9th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <?php
  2. require_once 'php-ews/EWSType.php';
  3. require_once 'php-ews/EWS_Exception.php';
  4. require_once 'php-ews/NTLMSoapClient.php';
  5. require_once 'php-ews/NTLMSoapClient/Exchange.php';
  6. require_once 'php-ews/ExchangeWebServices.php';
  7. require_once 'php-ews/EWSType/ItemType.php';
  8. require_once 'php-ews/EWSType/FindItemType.php';
  9. require_once 'php-ews/EWSType/ItemQueryTraversalType.php';
  10. require_once 'php-ews/EWSType/ItemResponseShapeType.php';
  11. require_once 'php-ews/EWSType/DefaultShapeNamesType.php';
  12. require_once 'php-ews/EWSType/CalendarItemType.php';
  13. require_once 'php-ews/EWSType/CalendarViewType.php';
  14. require_once 'php-ews/EWSType/NonEmptyArrayOfBaseFolderIdsType.php';
  15. require_once 'php-ews/EWSType/DistinguishedFolderIdType.php';
  16. require_once 'php-ews/EWSType/DistinguishedFolderIdNameType.php';
  17. require_once 'php-ews/EWSType/EmailAddressType.php';
  18. require_once 'php-ews/EWSType/BodyType.php';
  19. $today = Date("Y-m-d");
  20. $host = 'EXCHANGE.YOURSERVER.COM';
  21. $username = 'USERNAME';
  22. $password = 'PASSWORD';
  23. $localTZ = 'America/New_York';
  24. $daysahead = '1'; // Today Only
  25. $EWScalendar = 'EMAILADDRESSOFCALENDAR@YOURDOMAIN.COM';
  26. $ews = new ExchangeWebServices ($host, $username, $password);
  27. $request = new EWSType_FindItemType();
  28. $request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
  29. $request->ItemShape = new EWSType_ItemResponseShapeType();
  30. $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;
  31. $request->CalendarView = new EWSType_CalendarViewType();
  32. $request->CalendarView->StartDate = date ('c',strtotime("$today"));
  33. $request->CalendarView->EndDate = date ('c',strtotime("$today + $daysahead days"));
  34. $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
  35. $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
  36. $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
  37. $mailBox = new EWSType_EmailAddressType();
  38. $mailBox->EmailAddress = "$EWScalendar";
  39. $request->ParentFolderIds->DistinguishedFolderId->Mailbox = $mailBox;
  40. $response = $ews->FindItem($request);
  41. $TotalItemCount = $response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView;
  42.  
  43.  
  44.  
  45. // LOOP through the Event Data and Parse each item
  46.  
  47. echo '<?xml version="1.0" encoding="iso-8859-1" ?>' . "\n";
  48. ?>
  49. <rss version="2.0">
  50. <channel>
  51. <title>ROOM NAME</title>
  52. <copyright>WHOCARES</copyright>
  53. <link>http://DOESNOTMATTER.COM</link>
  54. <description>ROOM NAME</description>
  55. <?
  56.  
  57. if($TotalItemCount > 1)
  58. {
  59. for ( $ItemID = 0; $ItemID < $TotalItemCount; $ItemID++) {
  60. //--do something with item data--
  61. $subject = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem[$ItemID]->Subject;
  62. $startTS = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem[$ItemID]->Start;
  63. $endTS = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem[$ItemID]->End;
  64.  
  65. $startTS = strftime('%R', strtotime($startTS));
  66. $endTS = strftime('%R', strtotime($endTS));
  67.  
  68. ?>
  69. <item>
  70. <title><?=$subject?></title>
  71. <link>http://WHOCARES.COM/</link>
  72. <pubDate>Sat, 14 Feb 2006 18:58:46 GMT</pubDate>
  73. <description><?=$startTS?> - <?=$endTS?></description>
  74. </item>
  75. <?
  76.  
  77.  
  78. }
  79. }
  80. else if($TotalItemCount ==1)
  81. {
  82.  
  83. $subject = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem->Subject;
  84. $startTS = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem->Start;
  85. $endTS = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem->End;
  86. $startTS = strftime('%R', strtotime($startTS));
  87. $endTS = strftime('%R', strtotime($endTS));
  88.  
  89. ?>
  90. <item>
  91. <title><?=$subject?></title>
  92. <link>http://WHOCARES.COM/</link>
  93. <pubDate>Sat, 14 Feb 2006 18:58:46 GMT</pubDate>
  94. <description><?=$startTS?> - <?=$endTS?></description>
  95. </item>
  96. <?}?>
  97.  
  98. </channel>
  99. </rss>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement