我最近开始与 Jira 合作,并尝试在我的客户客户端门户上制作一个基于 Web 的表单,以允许人们输入问题。
通过我的搜索,我找到了 Jira 提供的 API 示例:https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-示例创建问题
然而,这仅使用了这些行:
curl -D- -u fred:fred -X POST --data {see below} -H
"Content-Type: application/json" http://localhost:8090/rest/api/2/issue/
然而curl是我以前从未使用过的东西。我已将其配置在我的服务器上以使其正常工作(进行了基本测试以确保其正常工作)。但我觉得这个设置不适用于 PHP。
在网上我发现它说将卷曲分成这样的部分:
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);
但我非常不确定如何将该命令分解到其中...也不确定如何接收它应该返回的数据(来自站点示例):
{
"id":"39002",
"key":"TEST-103",
"self":"http://localhost:8090/rest/api/2/issue/TEST-103"
}
任何有关在 PHP 中创建此类问题的提示都非常棒。
有很好的 SDK 可以使用:
https://github.com/chobie/jira-api-restclient
https://github.com/lesstif/php-jira-rest-client
然后您就可以使用 JIRA 提供大量功能和清晰的结构。第二个有更多的功能。
登录示例:
使用JiraRestApi\Configuration\ArrayConfiguration; 使用 JiraRestApi\Issue\IssueService;
$iss = new IssueService(new ArrayConfiguration(
array(
'jiraHost' => 'https://your-jira.host.com',
'jiraUser' => 'jira-username',
'jiraPassword' => 'jira-password',
)
));
如何使用上面的 $iss 变量检查登录情况