php-ews
在现有的非 OOP 网站上实施。
在 shell 中运行独立的 PHP 脚本可以正常工作。
独立的 PHP 脚本使用use
:
use \jamesiarmes\PhpEws\Client;
use \jamesiarmes\PhpEws\Request\CreateItemType;
但是我不能use
在网站上使用内部 if 语句,所以我使用完整路径(即new \jamesiarmes\PhpEws\Client
)在所有类前面添加。
现在我收到了这个错误。
Fatal error: Class 'SoapClient' not found in /home/project/master/vendor/jamesiarmes/php-ntlm/src/SoapClient.php on line 13
我确认已安装 Soap 扩展。请帮忙。谢谢。
if ($_REQUEST['action'] == 'export-form-test') {
require_once 'vendor/autoload.php';
/*
use \jamesiarmes\PhpEws\Client;
use \jamesiarmes\PhpEws\Request\CreateItemType;
use \jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAllItemsType;
use \jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAttendeesType;
use \jamesiarmes\PhpEws\Enumeration\BodyTypeType;
use \jamesiarmes\PhpEws\Enumeration\CalendarItemCreateOrDeleteOperationType;
use \jamesiarmes\PhpEws\Enumeration\ResponseClassType;
use \jamesiarmes\PhpEws\Enumeration\RoutingType;
use \jamesiarmes\PhpEws\Type\AttendeeType;
use \jamesiarmes\PhpEws\Type\BodyType;
use \jamesiarmes\PhpEws\Type\CalendarItemType;
use \jamesiarmes\PhpEws\Type\EmailAddressType;
*/
// Replace this with your desired start/end times and guests.
$start = new DateTime('tomorrow 4:00pm');
$end = new DateTime('tomorrow 5:00pm');
// Set connection information.
$host = '*********';
$username = '*******';
$password = '********';
//$version = Client::VERSION_2016;
$client = new \jamesiarmes\PhpEws\Client($host, $username, $password);
// Build the request,
$request = new \jamesiarmes\PhpEws\Request\CreateItemType();
$request->SendMeetingInvitations = \jamesiarmes\PhpEws\Enumeration\CalendarItemCreateOrDeleteOperationType::SEND_ONLY_TO_ALL;
$request->Items = new \jamesiarmes\PhpEws\ArrayType\NonEmptyArrayOfAllItemsType();
// Build the event to be added.
$event = new \jamesiarmes\PhpEws\Type\CalendarItemType();
$event->Start = $start->format('c');
$event->End = $end->format('c');
$event->title = 'EWS Test Event';
// Set the event body.
$event->Body = new \jamesiarmes\PhpEws\Type\BodyType();
$event->Body->_ = 'This is the event body';
$event->Body->BodyType = \jamesiarmes\PhpEws\Enumeration\BodyTypeType::TEXT;
// Add the event to the request. You could add multiple events to create more
// than one in a single request.
$request->Items->CalendarItem[] = $event;
$response = $client->CreateItem($request);
// Iterate over the results, printing any error messages or event ids.
$response_messages = $response->ResponseMessages->CreateItemResponseMessage;
foreach($response_messages as $response_message) {
// Make sure the request succeeded.
if ($response_message->ResponseClass != ResponseClassType::SUCCESS) {
$return_arr['status'] = 'error';
continue;
}
// Iterate over the created events, printing the id for each.
foreach($response_message->Items->CalendarItem as $item) {
$id = $item->ItemId->Id;
$return_arr['status'] = 'ok';
}
}
}