1. Creating Jira issue
$jiraUsername = 'Jira login username';
$jiraPassword = 'Jira login password';
$jiraHost = 'http://my-jira-host.com/';
$data = array(
'fields' => array(
'project' => array('key' => 'PR'/* Project Key*/),
'summary'=> 'Issue title',
'description' => 'Some text here, no html tags',
'labels' => array('API', 'IvanGospodinow'/* Put the username so you know which one added it */),
'issuetype' => array('id' => 1 /* or similar */)
)
);
$ch = curl_init();
$headers = array(
'Accept: application/json',
'Content-Type: application/json'
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_URL, $jiraHost . 'rest/api/2/issue/');
curl_setopt($ch, CURLOPT_USERPWD, "$jiraUsername:$jiraPassword");
$response = curl_exec($ch);
$error = curl_error($ch);
if (!empty($error)) {
throw new Exception('EQ Error: ' . $error);
}
curl_close($ch)
2. Getting all issues for user
$ch = curl_init();
$headers = array(
'Accept: application/json',
'Content-Type: application/json'
);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $jiraHost . 'rest/api/2/search?jql=' . urlencode('labels in (API, 'IvanGospodinow')'));
curl_setopt($ch, CURLOPT_USERPWD, "$jiraUsername:$jiraPassword");
$response = curl_exec($ch);
curl_close($ch);
Simple as that.