PHP code example of testmonitor / jira-client

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




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

$jira = new \TestMonitor\Jira\Client($oauth);

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

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

$jira = new \TestMonitor\Jira\Client($oauth);

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

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

$token = new \TestMonitor\Jira\AccessToken('eyJ0...', '0/34ccc...', 1574601877); // the token you got last time
$jira = new \TestMonitor\Jira\Client($oauth, null, $token);

$account = $jira->account();

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

$token = new \TestMonitor\Jira\AccessToken('eyJ0...', '0/34ccc...', 1574601877);
$jira = new \TestMonitor\Jira\Client($oauth, $account->id, $token);

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

$project = $jira->project('KEY');

$issueTypes = $jira->issueTypes('KEY');

$issue = $jira->createIssue(new \TestMonitor\Jira\Resources\Issue([
    'summary' => 'It is time Marty!',
    'description' => 'Great Scot!',
    'project' => $project,
    'type' => $issueType[0],
]));