2

我正在使用 PHP Exchange Web 服务库 ( https://github.com/jamesiarmes/php-ews ) 当前检索用户可用性没有问题。我想做的是为用户检索外出响应(如果已设置),并且似乎无法弄清楚如何正确设置请求。到目前为止我所拥有的:

$ews = new ExchangeWebServices();
$request = new EWSType_GetUserOofSettingsRequest();
$request->Mailbox->Address = 'TEstUser@Test.com';
$ewsResponse = $ews->GetUserOofSettings($request);

然而,我得到的只是:

stdClass Object
(
[ResponseMessage] => stdClass Object
    (
        [MessageText] => Connection did not succeed. Try again later.
        [ResponseCode] => ErrorConnectionFailed
        [DescriptiveLinkKey] => 0
        [ResponseClass] => Error
    )

)

关于如何正确设置此请求的任何想法?

编辑 由于我收到了一些来自用户的电子邮件,我觉得我会相应地更新这个问题。我不再有权访问 Exchange 环境来测试此代码,因此任何更新都会有所帮助!

以下代码来自我的 ldapAdapter 文件,可以按以下方式使用:

$request = createEWSRequest();
$request->MailboxDataArray->MailboxData->Email->Address = $email;
$ewsResponse = $ews->GetUserAvailability($request);
$fbtInfo = getFreeBusyTime();


private function getFreeBusyTime() {
    if (isset($this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray)) {
        if (is_array($this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent)) {
            $this->nextMeetingStart = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent[0]->StartTime;
            $this->nextMeetingEnd = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent[0]->EndTime;
            $this->busyType = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent[0]->BusyType;
        } else {
            $this->nextMeetingStart = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent->StartTime;
            $this->nextMeetingEnd = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent->EndTime;
            $this->busyType = $this->ewsResponse->FreeBusyResponseArray->FreeBusyResponse->FreeBusyView->CalendarEventArray->CalendarEvent->BusyType;
        }
        $this->meetingScheduled = true;

        $date = new DateTime($this->nextMeetingStart, new DateTimeZone('America/Chicago'));
        $date->setTimezone(new DateTimeZone('UTC'));
        $this->nextMeetingStart = $date->format(DateTime::W3C);

        $date = new DateTime($this->nextMeetingEnd, new DateTimeZone('America/Chicago'));
        $date->setTimezone(new DateTimeZone('UTC'));
        $this->nextMeetingEnd = $date->format(DateTime::W3C);
    } else {
        $this->meetingScheduled = false;
        $this->nextMeetingStart = false;
        $this->nextMeetingEnd = false;
        $this->busyType = false;
    }
}

private function createEWSRequest() {
    $request = new EWSType_GetUserAvailabilityRequestType();
    $request->TimeZone = new EWSType_SerializableTimeZone();
    $request->TimeZone->Bias = '360';
    $request->TimeZone->StandardTime = new EWSType_SerializableTimeZoneTime();
    $request->TimeZone->StandardTime->Bias = '0';
    $request->TimeZone->StandardTime->Time = '02:00:00';
    $request->TimeZone->StandardTime->DayOrder = '5';
    $request->TimeZone->StandardTime->Month = '1';
    $request->TimeZone->StandardTime->DayOfWeek = 'Sunday';
    $request->TimeZone->DaylightTime->Bias = '-60';
    $request->TimeZone->DaylightTime->Time = '02:00:00';
    $request->TimeZone->DaylightTime->DayOrder = '1';
    $request->TimeZone->DaylightTime->Month = '4';
    $request->TimeZone->DaylightTime->DayOfWeek = 'Sunday';
    $request->MailboxDataArray = new EWSType_ArrayOfMailboxData();
    $request->MailboxDataArray->MailboxData = new EWSType_MailboxData();
    $request->MailboxDataArray->MailboxData->Email = new EWSType_EmailAddress();
    $request->MailboxDataArray->MailboxData->Email->RoutingType = 'SMTP';
    $request->MailboxDataArray->MailboxData->AttendeeType = 'Required';
    $request->MailboxDataArray->MailboxData->ExcludeConflicts = false;
    $request->FreeBusyViewOptions = new EWSType_FreeBusyViewOptionsType();
    $request->FreeBusyViewOptions->TimeWindow = new EWSType_Duration();
    $request->FreeBusyViewOptions->MergedFreeBusyIntervalInMinutes = '30';
    $request->FreeBusyViewOptions->RequestedView = 'FreeBusy';

    $date = new DateTime();
    $this->startDate = date_format($date, DateTime::W3C);

    $date->modify('+8 hours');
    $this->endDate = date_format($date, DateTime::W3C);

    $request->FreeBusyViewOptions->TimeWindow->StartTime = $this->startDate; //'2013-04-01T15:00:00';
    $request->FreeBusyViewOptions->TimeWindow->EndTime = $this->endDate; //'2013-04-20T18:00:00';

    return $request;
}
4

1 回答 1

0

看看这个线程。似乎您必须指定您尝试从中收集信息的交换服务器以及您的访问凭据。希望有帮助;)

于 2013-06-19T07:34:27.627 回答