将MS Exchange和PHP与ExchangeWebServices链接起来


link MS Exchange and PHP with ExchangeWebServices?

我目前正在学习计算机科学,根据我的工作经验,我的工作导师建议我通过PHP网站(由我实现)向我的导师发送约会请求Microsoft交换议程。不幸的是,我不知道该怎么做....我在PHP,HTML和CSS方面有很好的知识,但我完全迷Microsoft Exchange,因为直到我的工作导师问我这个项目,我才真正了解Microsoft项目。

我的代码(文件:测试.php):

<?php
function __autoload($ExchangeWebServices)
{
// Start from the base path and determine the location from the class name,
$base_path = 'C:/wamp/www/new-ews2/php-ews';
$include_file = $base_path . '/' . str_replace('_', '/',             $ExchangeWebServices) . '.php';
return (file_exists($include_file) ? require_once $include_file : false);
} 
$server='test.fr';
$username='test@test.fr';
$password='testtest';
$ews = new ExchangeWebServices($server, $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('2015-06-20 -00'));
$request->CalendarView->EndDate = date('c', strtotime('2015-06-22 -00'));
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
var_dump($request); 
?>

当我进入我的谷歌浏览器并设置:localhost/new-ews/php-ews/test.php

页面结果 :

object(EWSType_FindItemType)[2]
public 'CalendarView' => 
object(EWSType_CalendarViewType)[4]
  public 'EndDate' => string '2015-06-22T02:00:00+02:00' (length=25)
  public 'MaxEntriesReturned' => null
  public 'StartDate' => string '2015-06-20T02:00:00+02:00' (length=25)
public 'ContactsView' => null
public 'DistinguishedGroupBy' => null
public 'FractionalPageItemView' => null
public 'GroupBy' => null
public 'IndexedPageItemView' => null
public 'ItemShape' => 
object(EWSType_ItemResponseShapeType)[3]
  public 'AdditionalProperties' => null
  public 'BaseShape' => string 'Default' (length=7)
  public 'BodyType' => null
  public 'ConvertHtmlCodePageToUTF8' => null
  public 'FilterHtmlContent' => null
  public 'IncludeMimeContent' => null
public 'ParentFolderIds' => 
object(EWSType_NonEmptyArrayOfBaseFolderIdsType)[5]
  public 'DistinguishedFolderId' => 
    object(EWSType_DistinguishedFolderIdType)[6]
      public 'ChangeKey' => null
      public 'Id' => string 'calendar' (length=8)
      public 'Mailbox' => null
  public 'FolderId' => null
public 'QueryString' => null
public 'Restriction' => null
public 'SortOrder' => null
public 'Traversal' => string 'Shallow' (length=7)

我现在不知道如何测试这段代码?我现在要问我的导师服务器/用户名/密码吗?还是我的代码好?我有什么改变吗?谢谢

编辑2:我可以在哪一行添加此代码? :/

有许多 API 可以通过 PHP 访问 EWS:

  • Jamesiarmes/php-ews
  • 更多来源

他们会让你开始。

编辑:

拥有代码后 - 您必须 1.单独包含您需要的所有文件 2. 添加自定义自动加载程序

此处的自述文件对两者都进行了描述。要解决上述错误,您必须至少包含文件ExchangeWebServices.php

编辑2:您并没有真正查询 EWS。生成查询,但不执行代码。当然,您需要帐户数据进行查询。

$response = $ews->FindItem($request);
相关文章:
  • 没有找到相关文章