Getting ms exchange server version using php-ews - php

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

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://learn.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.

Related

Dialogflow Crash in AWS Deployment

I deployed the same source code to AWS EC2 Linux instance, but it fails to display the response Text from dialogflow.
I checked the conversation history in Dialogflow console, it shows both request and response correctly. However, the dialogflow client(PHP) seems crashes after calling the function "detectIntent".
Unfortunately, got no way to find any logs.
Reinstalled Dialogflow Client Library
$formattedSession = $sessionsClient->sessionName($agent, $agentSession->session_id);
// Set Text Input
$textInput = new TextInput();
$textInput->setText($text);
$textInput->setLanguageCode($lang);
// Set Parameters
$optionalArgs = array();
$queryInput = new QueryInput();
$queryInput->setText($textInput);
$response = $sessionsClient->detectIntent($formattedSession, $queryInput, $optionalArgs);
$action = $response->getQueryResult()->getAction(); //The action name from the matched intent.
Hope the following experience helps others:
For my case, the php version is not compatible with one of the Google API library. Hence it crashes somewhere we cannot capture.
Solution: Uninstall PHP, and Install the compatible version of php.

Quickbooks ONline Using PHP from quickbooks-php from GitHub

I am using the quickbooks-php from GitHub. The version is quickbooks-php-master\docs\partner_platform\quickbooks-php-master\docs\partner_platform\example_app_ipp_v3.
I used this version 3 or 4 years ago and it work OK. Recently I wanted to try it again for a project. Since the last time I used it they only used OAUTH1 now they are using OAUTH2 for login and I'm not able to connect to my Sandbox account. I get a general error when the php coded tries to return the company name.
My question is do I need to make changes to the quickbooks-php-master\docs\partner_platform\example_app_ipp_v3 version in order to get it working again. I have the Development Keys (Client ID and Client Secret) from the developers site.
The config.php file is where you place these keys:
$token = 'xxx';
oauth_consumer_key = 'xxx';
`$oauth_consumer_secret = 'xxx';
The names of these keys have changed so it is a bit confusion as to whether these can work this way.
So the main question is does example_app_ipp_v3 work with OAUTH2 and if so can you direct me to the changes I need to make.
Any help on this would be great. If this version doesn't work with OAUTH2 I just need to know if that is the case so I can try something else.
OAuth2.0 support is being rolled out now. Check out the migration guide here:
https://github.com/consolibyte/quickbooks-php#oauth-10-to-oauth-20-migration
And the most recent updates. More updates to come. The configuration code changes a bit to accommodate the new OAuth 2.0 requirements:
$oauth_client_id = 'Q0ql65UCww8oAoiXfNdVyZ5WHoZ0kJ43XqstMhxGtM2UuA5WKu';
$oauth_client_secret = 'S60VXMXFygEOcb08DleS8iePUFyH81i4FhVrKaAB';
$sandbox = true; // When you're using development tokens
// This is the URL of your OAuth auth handler page
$quickbooks_oauth_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/oauth.php';
// This is the URL to forward the user to after they have connected to IPP/IDS via OAuth
$quickbooks_success_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/success.php';
// This is the menu URL script
$quickbooks_menu_url = 'http://sandbox.test/quickbooks-php/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
$dsn = 'mysqli://dev:password#localhost/quickbooks';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Scope required
$scope = 'com.intuit.quickbooks.accounting ';
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere(
QuickBooks_IPP_IntuitAnywhere::OAUTH_V2,
$sandbox,
$scope,
$dsn,
$encryption_key,
$oauth_client_id,
$oauth_client_secret,
$quickbooks_oauth_url,
$quickbooks_success_url);

Is it possible to add a ticket response as a specific user via the SoftLayer API using the PHP SOAP client?

I'm attempting to use the SoftLayer API (via the PHP client) to add an update to an existing ticket, as a specific user under our main account (a sibling to our API user).
What I'm trying to achieve is that as the API user, I call SoftLayer_Ticket::addUpdate, passing a SoftLayer_Ticket_Update object that looks similar to:
{
editorID: user1_id_here,
editorType: "USER",
entry: 'My update here'
}
I have user1's ID, however when I pass it in the SoftLayer_Ticket_Update object, the update is still attached as the API user:
{
createDate:"2016-05-17T08:24:50-07:00"
editorId:api_users_id
editorType:"USER"
entry:"Another update for our glorious leader..."
id:#########
ticketId:########
}
Snippet of the ticket update code:
$slClient = \SoftLayer_client::getClient("Ticket", $ticketID);
$ticketUpdateObj = new \stdClass();
$ticketUpdateObj->entry = $update;
$ticketUpdateObj->editorId = ######;
$ticketUpdateObj->editor = ######;
$ticketUpdateObj->editorType = "USER";
$result = $slClient->addUpdate($ticketUpdateObj);
...
(do other stuff here)
Is there any way to do this with the SoftLayer API? Or is the issue stemming from permissions given to the API user, or that I'm attempting to add the update as a sibling to the API user? Any help would be appreciated!
Our platform is older, so we are using an older version of the SoftLayer PHP SOAP client (guessing circa 2010/early 2011).
Thank you in advance!
Sorry, that is not possbile you cannot set the editorId, this value is set by the system with the userID of the user who updated the ticket.
Regards

How can I log into multiple accounts at the same time using the Google Api PHP Client

Background: We've got two Accounts that each hold several profiles.
I am developing an application in PHP using the provided API.
I can successfully retrieve data from both accounts separately, but whenever I instantiate the Google_Client object a second time (using a different variable name, of course), it instantly logs me out of the first account and overwrites the first account's settings.
Has anyone successfully managed to log into two accounts at the same time using the PHP API Client and could give me a hint on how to accomplish that?
Relevant code sections:
$client1 = new Google_Client();
$client1 ->setAssertionCredentials($omitted);
$client1 ->setClientId($id);
$client1 ->setAccessType('offline_access');
$gaClient1 = new Google_AnalyticsService($client);
//I can now successfully query the Analytics API, but when I do this
$client2 = new Google_Client();
//and query gaClient1 again, it throws a "you must login/401"-error
I guess the problem is that the api uses caching with files to handle request. Now when the second client is created, it is using the same cache folder and thus it is overwriting the previous settings.
now in your config.php is the following:
'ioFileCache_directory' =>
(function_exists('sys_get_temp_dir') ?
sys_get_temp_dir() . '/Google_Client' :
'/tmp/Google_Client')
This is the part that is always returning the same result. When creating a client, you can send in your own config array and it will be combined with the master. So you could use:
$client1 = new Google_Client(array('ioFileCache_directory' => '/tmp/dirclient1'));
$client2 = new Google_Client(array('ioFileCache_directory' => '/tmp/dirclient2'));
Also in your code you created a $client1, but later on you use $gaClient1 = new Google_AnalyticsService($client);. Shouldnt that be $gaClient1 = new Google_AnalyticsService($client1);?

Exchange Server 2007 Web Services PHP Class

Does anyone know of an open source PHP class (preferably BSD or MIT license) that will interface with the MS Exchange Server 2007 Web Services via. SOAP?
I am looking for a higher level class that has functionality for sending messages via. the web service.
I had this same problem, so I started building something, here:
https://github.com/rileydutton/Exchange-Web-Services-for-PHP
It doesn't do much yet (basically just lets you get a list of email messages from the server, and send email), but it would be good enough to use as a basic starting point for doing some more complicated things.
I have abstracted out a good bit of the complexity that you would have to slog through using php-ews. If you are looking to do some raw, powerful commands with the server, I would use php-ews...this is for folks who just happen to be working with an Exchange server and want an easy way to do some basic tasks.
Oh, and it is MIT licensed.
Hope that someone finds it useful!
Here is a class that you need: php-ews (This library makes Microsoft Exchange 2007 Web Services easier to implement in PHP).
You could find it at: http://code.google.com/p/php-ews/
There is only one example but that should give you the way to implement it.
Below you can find an implementation in order to:
connect to server
get the calendar events
Note: don't forget to fill-in blank variables. You would also need to include php-ews classes files (I used the __autoload PHP function).
$host = '';
$username = '';
$password = '';
$mail = '';
$startDateEvent = ''; //ie: 2010-09-14T09:00:00
$endDateEvent = ''; //ie: 2010-09-20T17:00:00
$ews = new ExchangeWebServices($host, $username, $password);
$request = new EWSType_FindItemType();
$request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;
$request->CalendarView->StartDate = $startDateEvent;
$request->CalendarView->EndDate = $endDateEvent;
$request->CalendarView->MaxEntriesReturned = 100;
$request->CalendarView->MaxEntriesReturnedSpecified = true;
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
$request->ParentFolderIds->DistinguishedFolderId->Mailbox->EmailAddress = $mail;
$response = $ews->FindItem($request);
echo '<pre>'.print_r($response, true).'</pre>';
Exchange server supports WebDAV:
http://www.troywolf.com/articles/php/exchange_webdav_examples.php
If all you want to do is send messages, you could just use SMTP:
http://ca2.php.net/manual/en/book.mail.php
I have been researching this same issue and I have yet to find a class specific to MS Exchange. However, if you feel up to learning and building the XML yourself, you may want to have a look at the NTLM SOAP classes at http://rabaix.net/en/articles/2008/03/13/using-soap-php-with-ntlm-authentication. This will allow you to authenticate against Active Directory to make your SOAP calls, which native PHP SOAP does not allow you to do. Another decent resource that uses the same method to connect to MS CRM is http://www.reutone.com/heb/articles_internet.php?instance_id=62&actions=show&id=521.
The examples under http://www.troywolf.com/articles/php/exchange_webdav_examples.php are for Exchange 2003 not 2007.

Categories