1. Go to this page and download the library: Download opendns/autotask-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
opendns / autotask-php example snippets
// This code is designed to find your exact wsdl location.
// If you already know your zone's wsdl URL, you can skip
// this step.
$username = '[email protected]';
$password = 'VeryVeryVeryVerySecurePassword';
$authWsdl = 'https://webservices.autotask.net/atservices/1.6/atws.wsdl';
$integrationCode = '27-character ID';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts, $integrationCode);
$zoneInfo = $client->getZoneInfo($username);
print_r($zoneInfo);
// This code is designed to find your exact wsdl location.
// If you already know your zone's wsdl URL, you can skip
// this step.
$username = '[email protected]';
$password = 'VeryVeryVeryVerySecurePassword';
$authWsdl = 'https://webservices.autotask.net/atservices/1.6/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$integrationCode = '27-character ID';
$client->setIntegrationCode($integrationCode);
$zoneInfo = $client->getZoneInfo($username);
print_r($zoneInfo);
// This code is designed to find your exact wsdl location.
// If you already know your zone's wsdl URL, you can skip
// this step.
$username = '[email protected]';
$password = 'VeryVeryVeryVerySecurePassword';
$authWsdl = 'https://webservices.autotask.net/atservices/1.5/atws.wsdl';
$opts = array('trace' => 1);
$client = new ATWS\Client($authWsdl, $opts);
$zoneInfo = $client->getZoneInfo($username);
print_r($zoneInfo);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$integrationCode = '27-character ID';
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts, $integrationCode);
// Instantiate an Account Note object and assign values
$accountNote = new ATWS\AutotaskObjects\AccountNote('Contact');
$accountNote->AccountID = 12345678;
$accountNote->ActionType = 1;
$accountNote->AssignedResourceID = 12345678;
$accountNote->EndDateTime = "2019-01-28T18:18:00";
$accountNote->id = 0;
$accountNote->Note = "Resource Impersonation Test";
$accountNote->StartDateTime = "2019-01-28T18:18:00";
$result = $client->setResourceImpersonation(87654321)->create($accountNote);
// Print the results of the account note creation
print_r($result);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$integrationCode = '27-character ID';
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts, $integrationCode);
$client->setResourceImpersonation(87654321);
// Instantiate an Account Note object and assign values
$accountNote = new ATWS\AutotaskObjects\AccountNote('Contact');
$accountNote->AccountID = 12345678;
$accountNote->ActionType = 1;
$accountNote->AssignedResourceID = 12345678;
$accountNote->EndDateTime = "2019-01-28T18:18:00";
$accountNote->id = 0;
$accountNote->Note = "Resource Impersonation Test";
$accountNote->StartDateTime = "2019-01-28T18:18:00";
$result = $client->create($accountNote);
// Print the results of the account note creation
print_r($result);
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts, $integrationCode); // for version 1.6
// $client = new ATWS\Client($wsdl, $authOpts); // for version 1.5 with no integration code
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
$firstnameField = new ATWS\AutotaskObjects\QueryField('firstname');
$firstnameField->addExpression('Equals', 'Steve');
$query->addField($firstnameField);
// If you want to debug the XML produced by the Query object
// print($query->asXml());
// Print the results of the query
print_r($client->query($query));
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts, $integrationCode); // for version 1.6
// $client = new ATWS\Client($wsdl, $authOpts); // for version 1.5 with no integration code
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
// Add a QueryField with multiple expressions
$firstnameField = new ATWS\AutotaskObjects\QueryField('firstname');
// Multiple Expressions in a single Field results in a logical OR
$firstnameField->addExpression('BeginsWith', 'S');
$firstnameField->addExpression('Contains', 'e');
$query->addField($firstnameField);
$lastnameField = new ATWS\AutotaskObjects\QueryField('lastname');
$lastnameField->addExpression('BeginsWith', 'M');
// Add a second QueryField -- multiple Fields are ANDed together
$query->addField($lastnameField);
// print($query->asXml());
print_r($client->query($query));
$authOpts = array(
'login' => $username,
'password' => $password,
'trace' => 1, // Allows us to debug by getting the XML requests sent
);
$wsdl = str_replace('.asmx', '.wsdl', $zoneInfo->getZoneInfoResult->URL);
$client = new ATWS\Client($wsdl, $authOpts, $integrationCode); // for version 1.6
// $client = new ATWS\Client($wsdl, $authOpts); // for version 1.5 with no integration code
// Instantiate a Query object, designed to make complex
// queries simple.
$query = new ATWS\AutotaskObjects\Query('Contact');
// QueryConditions default to logical ANDs. If you want to
// using logcal OR, specify it when creating the QueryCondition
$wrappingCondition = new ATWS\AutotaskObjects\QueryCondition('OR');
$conditionOne = new \ATWS\AutotaskObjects\QueryCondition();
$conditionTwo = new \ATWS\AutotaskObjects\QueryCondition('OR');
$firstField = new ATWS\AutotaskObjects\QueryField('firstname');
$firstField->addExpression('Equals', 'Joe');
$secondField = new ATWS\AutotaskObjects\QueryField('firstname');
$secondField->addExpression('Equals', 'Larry');
$thirdField = new ATWS\AutotaskObjects\QueryField('lastname');
$thirdField->addExpression('Equals', 'Brown');
$fourthField = new ATWS\AutotaskObjects\QueryField('firstname');
$fourthField->addExpression('Equals', 'Mary');
$fifthField = new ATWS\AutotaskObjects\QueryField('lastname');
$fifthField->addExpression('Equals', 'Smith');
$sixthField = new ATWS\AutotaskObjects\QueryField('city');
$sixthField->addExpression('NotEqual', 'Albany');
// AND together the 2nd and 3rd fields into a condition
$conditionOne->addField($secondField);
$conditionOne->addField($thirdField);
// AND together the 4th and 5th fields into a condition
$conditionTwo->addField($fourthField);
$conditionTwo->addField($fifthField);
// OR together the 1st Condition and 2nd Condition
// NOTE: This is an OR because of how $conditionTwo
// was defined
$wrappingCondition->addCondition($conditionOne);
$wrappingCondition->addCondition($conditionTwo);
// Add the 1st Field to the Query
$query->addField($firstField);
// OR together the 1st Field and the wrapping Condition
// NOTE: This is an OR because of how $wrappingCondition
// was defined.
$query->addCondition($wrappingCondition);
// AND together the 6th Field and (1st Field OR wrapping Condition)
$query->addField($sixthField);
// If you want to debug the XML produced by the Query object
// print($query->asXml());
// Print the results of the query
print_r($client->query($query));
json
{
"pendns/autotask-php": "dev-master"
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.