【问题标题】:link MS Exchange and PHP with ExchangeWebServices?将 MS Exchange 和 PHP 与 ExchangeWebServices 联系起来?
【发布时间】:2015-09-02 08:38:09
【问题描述】:

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

我的代码(文件:test.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)

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

edit 2:请问我可以在哪一行添加此代码? :/

【问题讨论】:

  • 天哪,这是什么级别的工作经验?!
  • 疯狂.. 你的 w/e 导师需要一个叫醒电话。明天生日快乐
  • 为什么? :x 对我的等级来说太难了吗? :/ 谢谢兄弟'!

标签: php exchange-server exchangewebservices php-ews


【解决方案1】:

通过 PHP 访问 EWS 的 API 有很多:

他们会让你开始。

编辑:

获得您的代码后 - 您必须 1. 分别包含你需要的所有文件 2.添加自定义自动加载器

自述文件here 中描述了两者。 要解决上述错误,您必须至少包含文件ExchangeWebServices.php

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

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

【讨论】:

  • 请编辑您的问题并提供更多详细信息。您已经拥有的相关代码部分,以及您得到的结果/错误消息。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-06-20
  • 1970-01-01
  • 2012-04-09
  • 2015-06-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多