-
Notifications
You must be signed in to change notification settings - Fork 1
/
user_list.php
54 lines (43 loc) · 1.58 KB
/
user_list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
error_reporting(E_ALL);
$ckfile = tempnam ("/tmp", "CURLCOOKIE");
/***** EDIT THIS *****/
define('JIRA_URL', 'https://yourcompany.atlassian.net'); // your jira host
define('USERNAME', 'username'); // username
define('PASSWORD', 'password'); // password
define('MAX_RESULTS','200'); // query maximum results
/*********************/
$fields = array('username'=>USERNAME, 'password'=>PASSWORD);
$jsonString = json_encode($fields);
$searchUrl = '/rest/api/2/search?jql=';
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, JIRA_URL."/rest/auth/1/session");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $jsonString);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json"));
curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$ch = curl_init (JIRA_URL.$searchUrl."(assignee=".USERNAME."%20AND%20status=open)&startAt=0&maxResults=".MAX_RESULTS);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec ($ch);
$obj = json_decode($output,true);
$issues = $obj['issues'];
echo "100%;
";
if (count($issues)==0) {
echo "No issues;
";
}
else {
for ($i=0;$i<count($issues);$i++) {
$iss = $issues[$i];
$fields = $iss['fields'];
$status = $fields['summary'];
echo $status.";
";
}
}