PHP code example of lexonouri / serwisant-api

1. Go to this page and download the library: Download lexonouri/serwisant-api 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/ */

    

lexonouri / serwisant-api example snippets


use Serwisant\SerwisantApi;

// get own client and secret by creating an application via webpage
// 4th argument is a access token cache, it's optional, but recommended for performance reasons
$access_token = new SerwisantApi\AccessTokenOauth('client', 'secret', 'public', (new SerwisantApi\AccessTokenContainerFile));

$api = new SerwisantApi\Api();
$api->setAccessToken($access_token);

/* please note __typename at each type - it's rByToken(token: $token) {
      __typename
      displayName
      status {
        __typename
        displayName
      }
    }
}';

/* @var SerwisantApi\Types\SchemaPublic\Repair $repair */
$repair = $api->publicQuery()->newRequest()->set($query, ['token' => 'abc-def'])->execute()->fetch();
 
echo $repair->displayName;
echo $repair->status->displayName;

/* please note __typename at each type - it's  repairByToken(token: $token) {
    __typename
    displayName
  }
  me: viewer {
    __typename
    employee {
      __typename
      displayName
    }
  } 
}';

$result = $api->publicQuery()->newRequest()->set($query, ['token' => 'abc-def'])->execute();

$repair = $result->fetch('repair');
$me = $result->fetch('me');

echo $repair->displayName;
echo $me->displayName;