Issues (3541)

samples/inbox/GetItem.php (12 issues)

Labels
Severity
1
<?php
2
/**
3
 * Composer autoload
4
 */
5
require_once __DIR__ . '/../../vendor/autoload.php';
6
7
/**
8
 * Used classes
9
 */
10
use WsdlToPhp\PackageBase\AbstractSoapClientBase;
11
use Ews\EnumType\EwsExchangeVersionType;
0 ignored issues
show
The type Ews\EnumType\EwsExchangeVersionType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Ews\EwsClassMap;
0 ignored issues
show
The type Ews\EwsClassMap was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
This use statement conflicts with another class in this namespace, EwsClassMap. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
13
use Ews\StructType\EwsGetItemType;
0 ignored issues
show
The type Ews\StructType\EwsGetItemType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Ews\StructType\EwsItemResponseShapeType;
0 ignored issues
show
The type Ews\StructType\EwsItemResponseShapeType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Ews\EnumType\EwsDefaultShapeNamesType;
0 ignored issues
show
The type Ews\EnumType\EwsDefaultShapeNamesType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Ews\StructType\EwsRequestServerVersion;
0 ignored issues
show
The type Ews\StructType\EwsRequestServerVersion was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Ews\EnumType\EwsBodyTypeResponseType;
0 ignored issues
show
The type Ews\EnumType\EwsBodyTypeResponseType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Ews\StructType\EwsNonEmptyArrayOfBaseItemIdsType;
0 ignored issues
show
The type Ews\StructType\EwsNonEmptyArrayOfBaseItemIdsType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use Ews\StructType\EwsItemIdType;
0 ignored issues
show
The type Ews\StructType\EwsItemIdType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use Ews\StructType\EwsContactItemType;
0 ignored issues
show
The type Ews\StructType\EwsContactItemType was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
22
/**
23
 * Your Office 365 login
24
 */
25
define('EWS_WS_LOGIN', '***************************');
26
/**
27
 * Your Office 365 passowrd
28
 */
29
define('EWS_WS_PASSWORD', '*************');
30
31
/**
32
 * Minimal options in order to instanciate the ServiceType named Get
33
 */
34
$options = array(
35
    AbstractSoapClientBase::WSDL_URL => __DIR__ . '/../../wsdl/services.updated.wsdl',
36
    AbstractSoapClientBase::WSDL_CLASSMAP => EwsClassMap::get(),
37
    AbstractSoapClientBase::WSDL_LOGIN => EWS_WS_LOGIN,
38
    AbstractSoapClientBase::WSDL_PASSWORD => EWS_WS_PASSWORD,
39
);
40
41
/**
42
 * Instanciation of the ServiceType get that gather all the operations beginnig with "get".
43
 */
44
$get = new \Ews\ServiceType\EwsGet($options);
0 ignored issues
show
The type Ews\ServiceType\EwsGet was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
45
$get->setLocation('https://pod51036.outlook.com/ews/Exchange.asmx');
46
/**
47
 * Configure the SoapHeader, each header's method begins with "setSoapHeader".
48
 */
49
$get->setSoapHeaderRequestServerVersion(new EwsRequestServerVersion(EwsExchangeVersionType::VALUE_EXCHANGE_2013_SP_1));
50
/**
51
 * Send the request with your actual ID
52
 * inbox item id : AQMkADdmZTc2Y2EwLWM4QtNGNkYi1iOTZhLTI4ZTIzNjEwZGIzZgBGAAAD4a54IMUm0UC0Oie/nN4R4AcAHM3Rq81r8UGBMGXZ2QDPNOoAAAIBDAAAADSezQdp0a5Anuxdk9hQzRAAAAIFUQAAAA==
53
 * calendar item id : AAMkADdmZTc2Y2EwL4YmQtNGNkYi1iOTZhLTI4ZTIzNjEwZGIzZgBGAAAAAADhrnggxSbRQLQ6J7+c3hHgBwAczdGrzWvxQYEwZdnZzzTqAAAAAAENAAA0ns0HadGuQJ7sXZPYUM0QAAAVnj3eAAA=
54
 * taks item id : AAMkADdmZTc2Y2EwLWM4YtNGNkYi1iOTZhLTI4ZTIzNjEwZGIzZgBGAAAAAADhrnggxSbRQLQ6J7+c3hHgBwAczdGrzWvxQYEwZdnZzzTqAAAAAAESAAA0ns0HadGuQJ7sXZPYUM0QAAAVnkW1AAA=
55
 * contac titme id : AAMkADdmZTc2Y2EwLWYmQtNGNkYi1iOTZhLTI4ZTIzNjEwZGIzZgBGAAAAAADhrnggxSbRQLQ6J7+c3hHgBwAczdGrzWvxQYEwZdnZzzTqAAAAAAEOAAA0ns0HadGuQJ7sXZPYUM0QAAAVnjYCAAA=
56
 */
57
$itemType = new EwsGetItemType();
58
$shapeType = new EwsItemResponseShapeType();
59
$shapeType
60
    ->setBaseShape(EwsDefaultShapeNamesType::VALUE_ALL_PROPERTIES)
61
    ->setBodyType(EwsBodyTypeResponseType::VALUE_BEST);
62
$itemType
63
    ->setItemShape($shapeType)
64
    ->setItemIds(
65
        new EwsNonEmptyArrayOfBaseItemIdsType(
66
            new EwsItemIdType('******************************************************************************************************************************************************')
67
            )
68
        );
69
$result = $get->GetItem($itemType);
70
71
/**
72
 * Debug informations provided by the utility methods
73
 */
74
if (false) {
75
    echo 'XML Request: ' . $get->getLastRequest() . "\r\n";
76
    echo 'Headers Request: ' . $get->getLastRequestHeaders() . "\r\n";
77
    echo 'XML Response: ' . $get->getLastResponse() . "\r\n";
78
    echo 'Headers Response: ' . $get->getLastResponseHeaders() . "\r\n";
79
}
80
81
if ($result !== false) {
82
    /**
83
     * Display the item data depending on its type:
84
     */
85
    foreach($result->getResponseMessages()->getGetItemResponseMessage() as $message) {
86
        /**
87
         * In case of a Contact Item
88
         */
89
        if (is_array($message->getItems()->getContact())) {
90
            foreach($message->getItems()->getContact() as $item) {
91
                if ($item instanceof EwsContactItemType) {
92
                    $addresses = $item->getEmailAddresses()->getEntry();
93
                    echo PHP_EOL . sprintf('Contact "%s %s <%s>"',
94
                        $item->getCompleteName()->getFirstName(),
95
                        $item->getCompleteName()->getLastName(),
96
                        is_array($addresses) ? array_shift($addresses)->get_() : '');
97
                }
98
            }
99
        }
100
        echo  PHP_EOL;
101
    }
102
} else {
103
    /**
104
     * In this case, we get the \SoapFault object
105
     */
106
    print_r($get->getLastErrorForMethod('\Ews\ServiceType\EwsGet::GetItem'));
107
}