Jira Soap with a Php

試著忘記壹切 提交于 2019-12-30 11:34:09

问题


I have seen little to know instruction on using php to develop a client website to make remote calls to JiRA.

Currently I'm trying to make a soap client using JSP/Java to connect to a local jira instance. I would like to create and search issues that is all. We are currently having some problems using Maven2 and getting all the files we need from the repository since we are behind a major firewall(yes I've used the proxy).

I have a lot of experience with PHP and would like to know if using the PHP soapclient calls can get the job done.

http://php.net/manual/en/soapclient.soapclient.php


回答1:


Yes it can be done, using SOAP or XML-RPC.

Using the APIs is pretty much straight forward - have a look at the API documentation to find the right functions for you. your code should look something like :

<?
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
...  
... # get/create/modify issues
... 
?>

Example of adding a new comment:

$issueKey = "key-123";
$myComment = "your comment";

$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->addComment($token, $issueKey, array('body' => $myComment));

Example of creating an issue:

$issue = array(
    'type'=>'1',
    'project'=>'TEST',
    'description'=>'my description',
    'summary'=>'my summary',
    'priority'=>'1',
    'assignee'=>'user',
    'reporter'=>'user',
);
$soapClient = new SoapClient("https://your.jira/rpc/soap/jirasoapservice-v2?wsdl");
$token = $soapClient->login('user', 'password');
$soapClient->createIssue($token, $issue);

Note that you need to install php-soap in linux (or it's equivalent in windows) to be able to use the SOAP library.



来源:https://stackoverflow.com/questions/12181637/jira-soap-with-a-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!