PHP code example of apility / 24sevenoffice

1. Go to this page and download the library: Download apility/24sevenoffice 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/ */

    

apility / 24sevenoffice example snippets




use Apility\T4SevenOffice\T4SevenOffice;

T4SevenOffice::setCredentials(
  '[email protected]', // username
  'yourpassword123', // password
  '00000000-0000-0000-0000-000000000000', // applicationId
  '00000000-0000-0000-0000-000000000000' // identityId (optional)
);

// By default, this is set to false, since you most likely would 
// like to save the sessionId from 24SevenOffice some other place
T4SevenOffice::setUsePhpSession(true);

try {
  
  T4SevenOffice::authenticateService();
  
  $companyService = T4SevenOffice::companyService();
  
  $companies = $companyService->GetCompanies([
    'searchParams' => ['CompanyName' => 'Test'],
    'returnProperties' => ['Name', 'Id']
  ]);
  
  var_dump($companies);
  
} catch (Exception $e) {
  die('24SevenOffice Exception: '.$e->getMessage());
}



// By default, this is set to false
T4SevenOffice::setUsePhpSession(true);



// Saved from last auth
$sessionId = 'demosw1avyg2h4opyi0demo';

T4SevenOffice::setSessionId($sessionId);

T4SevenOffice::authenticateService();

if ($sessionId !== T4SevenOffice::getSessionId) {
  // Session from last time is no longer valid, and a new one has been created
  // TODO: Save the new sessionId for next time
}



T4SevenOffice::setCredentials(
  '[email protected]', // username
  'yourpassword123', // password
  '00000000-0000-0000-0000-000000000000' // applicationId
);

$authService = T4SevenOffice::authenticateService();
  
$identities = $authService->GetIdentities();
  
var_dump($identities);