0
votes

I am using php-ews library(new version) to display the calendar events of the users in my project. The users can set their ms exchange account details in their profile and then use the calendar within my project itself. The code is like below

$host = '{host_set_on_users_profile}';
$username = '{username_set_on_users_profile}';
$password = '{password_set_on_users_profile}';
$version = Client::VERSION_2016;

$client = new Client($host, $username, $password, $version);
$client->setTimezone($timezone);

// Build request
$request = new FindItemType();
// more request building code here

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

But I am getting the below issue

[faultstring] => The specified server version is invalid.

The reason is I have used fixed VERSION_2016 and the users can have any version of ms exchange set up for the account.

So is there any way using which first I can find out the server version based on host,username and password? so that I can use the same for creating the client object

1

1 Answers

0
votes

To your question: normally when you execute a request to the Exchange within the response you also get the version of the responding Exchange server. See the header element in the documentation at https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/expanddl-operation#successful-expanddl-response-example Although you don't get a good readable year version this version number corresponds to a certain version.

Having said this, you can for example make a first simple dummy request like expandDL with a dummy mail address and get then the version for all your subsequent requests. Or even better you set for your very first FindItem request the version to 2007 and retrieve then with the response the correct version.

Another option would be to set your request version always to 2007 which is the lowest possible. You can do this if you don't need functionality from later Exchange Versions like GetInboxRule or GetPhoneCallInformation.