Example #1
0
 /**
  * Test that building the client works
  */
 public function testBuildClient()
 {
     $api = new API();
     $api->buildClient('test.com', 'username', 'password');
     //Create our expected item, get our class to build our item, then compare
     $expected = new ExchangeWebServices('test.com', 'username', 'password', ['version' => ExchangeWebServices::VERSION_2010]);
     $actual = $api->getClient();
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 public function getClient()
 {
     $mode = getenv('HttpPlayback');
     if ($mode == false) {
         $mode = 'playback';
     }
     $auth = ['server' => 'server', 'user' => 'user', 'password' => 'password'];
     if (is_file(getcwd() . '/Resources/auth.json')) {
         $auth = json_decode(file_get_contents(getcwd() . '/Resources/auth.json'), true);
     }
     $client = new API();
     $client->buildClient($auth['server'], $auth['user'], $auth['password'], ['httpPlayback' => ['mode' => $mode, 'recordFileName' => self::class . '::' . $this->getName() . '.json']]);
     return $client->getClient()->getClient();
 }
Example #3
0
<?php

/**
 * Quick Start
 *
 * This file is an example of how to quickly create a Calendar Item without going through the CalendarAPI, to show
 * that you can create items directly
 */
//Include the API
use jamesiarmes\PEWS\API;
use jamesiarmes\PEWS\API\Enumeration;
//Create and build the client
$api = new API();
$api->buildClient('server', 'username', 'password');
//Get the folder to save the event to
$folderId = $api->getFolderByDistinguishedId('calendar');
//Create our event
$item = array('CalendarItem' => array('Start' => (new \DateTime('8:00 AM'))->format('c'), 'Subject' => 'The Event Subject'));
//Set our options
$options = array('SendMeetingInvitations' => Enumeration\CalendarItemCreateOrDeleteOperationType::SEND_TO_NONE, 'SavedItemFolderId' => array('FolderId' => array('Id' => $folderId->Id)));
//Send the request
$items = $api->createItems($item, $options);