简体   繁体   English

使用PHP和curl创建一个Jira问题

[英]Create a Jira Issue Using PHP and curl

I have recently started working with Jira and am trying to make a web based form on my customer client portal that will allow people to enter issues. 我最近开始与Jira合作,正在尝试在我的客户客户门户上创建一个基于Web的表单,该表单将允许人们输入问题。

From my searching I have found the API examples Jira provides: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue 通过搜索,我发现了Jira提供的API示例: https : //developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-创建问题

However this uses something alone these lines: 但是,这仅使用了以下几行:

curl -D- -u fred:fred -X POST --data {see below} -H 
"Content-Type: application/json" http://localhost:8090/rest/api/2/issue/

However curl is something I have never used before. 但是卷曲是我从未使用过的东西。 I have it configured in on my server to work (did a basic test to ensure it does). 我已在服务器上将其配置为可以正常工作(进行了基本测试以确保能够正常运行)。 But I feel like this setup is not how it works for PHP. 但是我觉得这种设置不适用于PHP。

Online I find it says to break the curl into parts like this: 在网上我发现它说可以将卷发分成如下部分:

$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);

but I am very unsure how I would break that command into it... also unsure how I would receive the data it is supposed to return (From the sites example): 但是我非常不确定如何将命令分解为命令...也不确定如何接收应该返回的数据(来自站点示例):

{
   "id":"39002",
   "key":"TEST-103",
    "self":"http://localhost:8090/rest/api/2/issue/TEST-103"
}

Any tips for going about creating an issue in PHP like this would be fantastic. 像这样在PHP中创建问题的任何提示都是很棒的。 Thanks. 谢谢。

There are good SDKs to work with: 有很好的SDK可以使用:

https://github.com/chobie/jira-api-restclient https://github.com/chobie/jira-api-restclient

https://github.com/lesstif/php-jira-rest-client https://github.com/lesstif/php-jira-rest-client

Then you have a lot of function and a clean structure to work with JIRA. 这样,您便可以使用JIRA,具有许多功能和简洁的结构。 The second one has more function. 第二个功能更多。

Login example: 登录示例:

use JiraRestApi\\Configuration\\ArrayConfiguration; 使用JiraRestApi \\ Configuration \\ ArrayConfiguration; use JiraRestApi\\Issue\\IssueService; 使用JiraRestApi \\ Issue \\ IssueService;

$iss = new IssueService(new ArrayConfiguration(
   array(
      'jiraHost' => 'https://your-jira.host.com',
      'jiraUser' => 'jira-username',
      'jiraPassword' => 'jira-password',
   )
));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM