PHP code example of testmonitor / devops-client

1. Go to this page and download the library: Download testmonitor/devops-client 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/ */

    

testmonitor / devops-client example snippets




$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'appId' => '12345',
    'redirectUrl' => 'https://redirect.myapp.com/',
];

$devops = new \TestMonitor\DevOps\Client($oauth);

header('Location: ' . $devops->authorizationUrl());
exit();

$oauth = [
    'clientId' => '12345',
    'clientSecret' => 'abcdef',
    'appId' => '12345',
    'redirectUrl' => 'https://redirect.myapp.com/',
];

$devops = new \TestMonitor\DevOps\Client($oauth);

$token = $devops->fetchToken($_REQUEST['code']);

$oauth = ['clientId' => '12345', 'clientSecret' => 'abcdef', 'appId' => '12345', 'redirectUrl' => 'https://redirect.myapp.com/'];
$token = new \TestMonitor\DevOps\AccessToken('eyJ0...', '0/34ccc...', 1574601877); // the token you got last time
$organization = 'MyOrg';

$devops = new \TestMonitor\DevOps\Client($oauth, $organization, $token);

if ($token->expired()) {
    $newToken = $devops->refreshToken();
}

$accounts = $devops->accounts();

$workItem = $devops->createWorkItem(new \TestMonitor\DevOps\Resources\WorkItem([
    'title' => 'Summary of the item',
    'description' => 'Some description',
    'workItemType' => 'Bug',
    'stepsToReproduce' => 'Repro steps',
]), '12345');