Bugzilla API: an example using PHP and Zend Framework

Bugzilla has a rudimentary API for driving it from code.  To do this from PHP is reasonably trivial, but using Zend Framework (for the cookie jar primarily) makes the task very simple.  Here is some example code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$oClient = new Zend_XmlRpc_Client('http://my.zilla.url/xmlrpc.cgi');
 
$oHttpClient = new Zend_Http_Client();
$oHttpClient->setCookieJar();
$oClient->setHttpClient($oHttpClient);
 
$aResponse = $oClient->call('User.login', array(array(
    'login'    => 'peterh@mydomain.com',
    'password' => 'mypassword',
    'remember' => 1
)));
 
$aResponse = $oClient->call('Bug.create', array(array(
    'product'     => "My Product",
    'component'   => "My Component",
    'summary'     => "This is the summary of the bug I'm creating",
    'version'     => "unspecified",
    'description' => "This is a description of the bug",
    'op_sys'      => "All",
    'platform'    => "---",
    'priority'    => "P5",
    'severity'    => "Trivial"
)));
$iBugId = $aResponse['id'];
 
$aResponse = $oClient->call('User.logout');
This entry was posted in Geek, Technologies, Uncategorized and tagged , , , . Bookmark the permalink.

2 Responses to Bugzilla API: an example using PHP and Zend Framework

  1. Hey there,
    thanks for this post.
    This is my first task, which is going to work with the Zend-Framework, I would like to read a Bug of Bugzilla, getting the version-number is working, but Bug.get_bugs (Bugzilla 3.0.4) doesn’t.

    But at all: now I am playing with the Zend framework, let’s have a look if I can use it in private projects ;P

    PS: is the Zend Framework that slow, that reading the Bugzilla version takes 5 second or is this the windows machine which is my working machin? :P

  2. Francisco Mancardi says:

    Your code works like a charm!!. Thanks for sharing it
    I will try to use it on TestLink (www.teamst.org) in order to integrate with Buzgilla without having to request DB access.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">