0

私はhttps://github.com/jamesiarmes/php-ewsを使用して、php を交換サーバーに接続しています。特定のユーザーのメール ボックスに接続して、すべてのカレンダー イベントを取得できます。今、私が望むすべてのイベントをプルするのは、「Student Appt」と言うことができるカレンダーイベントのみをプルすることです。可能ですか??

require_once('bug/dBug.php');
require_once('EWSType.php');
require_once('ExchangeWebServices.php');
require_once('NTLMSoapClient.php');
require_once('NTLMSoapClient/Exchange.php');
require_once('EWS_Exception.php');
require_once('EWSType/FindItemType.php');
require_once('EWSType/ItemQueryTraversalType.php');
require_once('EWSType/ItemResponseShapeType.php');
require_once('EWSType/DefaultShapeNamesType.php');
require_once('EWSType/CalendarViewType.php');
require_once('EWSType/NonEmptyArrayOfBaseFolderIdsType.php');
require_once('EWSType/DistinguishedFolderIdType.php');
require_once('EWSType/DistinguishedFolderIdNameType.php');
require_once('EWSType/EmailAddressType.php');
require_once('EWSType/UserIdType.php');
require_once('EWSType/CalendarEventDetails.php');


$host = 'xxx';
$username = 'xxx';
$password = 'xxx';
$version = 'Exchange2010';

$start = " 2013-04-17T15:18:34+03:00";
$end   = " 2013-04-30T15:18:34+03:00";

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



//new dBug ($ews);


// Set init class
$request = new EWSType_FindItemType();
// Use this to search only the items in the parent directory in question or use ::SOFT_DELETED
// to identify "soft deleted" items, i.e. not visible and not in the trash can.
$request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
// This identifies the set of properties to return in an item or folder response
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::DEFAULT_PROPERTIES;

// Define the timeframe to load calendar items
$request->CalendarView = new EWSType_CalendarViewType();
$request->CalendarView->StartDate = $start ;// an ISO8601 date e.g. 2012-06-12T15:18:34+03:00
$request->CalendarView->EndDate = $end ; // an ISO8601 date later than the above

// Only look in the "calendars folder"
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;




// if you want to get to someones folder 
while($info = mysql_fetch_array( $call_pri_result )){

    $EmailAddy = 'abc@exchangeserver.com';    
    $mailBox = new EWSType_EmailAddressType();
    $mailBox->EmailAddress = $EmailAddy;
    $request->ParentFolderIds->DistinguishedFolderId->Mailbox = $mailBox;

    echo 'Now Looping for Consular ID '.$EmailAddy.'<br>' ;


// Send request
    $response = $ews->FindItem($request);

    // Loop through each item if event(s) were found in the timeframe specified
    if ($response->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView > 0){
        $events = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->CalendarItem;
        foreach ($events as $event){
            $id = $event->ItemId->Id;
            $change_key = $event->ItemId->ChangeKey;
            $start = $event->Start;
            $end = $event->End;
            $subject = $event->Subject;
            //$location = $event->Location;
        }
    }
    else {
        // No items returned
    }



}
4

1 に答える 1