Wednesday, February 2, 2011

Bugzilla API Request via PHP

Have you tried to use the Bugzilla API and fell flat on the face unless you are using Python, Perl, C#, Java or anything but PHP (I still like PHP). Sadly I couldn't get any XMLRPC clients to work with the xmlrpc.cgi because prior to 3.6 versions of the API, Bugzilla authenticated via cookies. Zend Framework seems to support this but it also happens to be a lot of work just to create a ticket. Well fear not, I RTFM over and over and found this little note:

You can specify Bugzilla_login and Bugzilla_password as arguments to any WebService method, and you will be logged in as that user if your credentials are correct.


Documented in a very obscure place and 3.6 documentation is not the first to come up on Google. Here is some code via Codeigniter that does the trick but I assume any XMLRPC client will do the job with this concept.

$this->xmlrpc->server('', 80);

$request = array('Bugzilla_login'=>'', 'Bugzilla_password'=>'your_password', 'product'=>'Your Product Name', 'component'=>'User Submitted', 'summary'=>'Test', 'version'=>'x.x', 'description'=>'asdas');

$this->xmlrpc->request(array(array($request, 'struct')),'struct');

if(!$this->xmlrpc->send_request()) {
echo $this->xmlrpc->display_error();

// this returns ticket ID

Enjoy this, took me a while to figure it out.


Anonymous said...

I'm glad you did get that figured out--I didn't realize that that documentation was so hard to find! Your post inspired me to create a centralized wiki page where all the WebService documentation is linked from, so that people can find it more easily:


Boris Cosic said...

That's awesome and thanks a lot. Loving Bugzilla.

Gautam Kakdiya said...

Thank's Boris Cosic's, That's awesome and thanks a lot...

Post a Comment