I'm currently studying computer science and in my work experience my work tutor proposed me to send requests for appointments via a site in PHP (realised by me) to my tutor Microsoft EXCHANGE agenda's. Unfortunately I don't know how to do this.... I have good knowledges in PHP, HTML and CSS but I'm totaly lost speaking Microsoft Exchange because until my work tutor ask me this project, i didnt really know Microsoft Project.
my code (file : 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='[email protected]';
$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);
?>
When i go in my google chrome and set: localhost/new-ews/php-ews/test.php
result of the page :
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)
I don't know how to test this code now? Do i ask my tutor the server / username / password now? or is my code good? Do i change anything? thanks
edit 2 : On which line can i add this code please? :/
There are many APIs for accessing EWS via PHP:
They will get you started.
edit:
After having your code - you must 1. include all files you need separately 2. add a custom auto loader
Both is described in the readme document here. For solving the above error, you will have to include the file
ExchangeWebServices.php
at least.edit 2: You do not really query the EWS. You build the query - but do not execute the code. Of course you will need account data for querying.