A PHP class for interacting with the FogBugz API. FogBugz is issue tracking software developed by Fogcreek (Joel Spolsky). In their own words:
Used by over 20,000 software development teams for issue and bug tracking, project planning and management, collaboration and time tracking. All in one place.
The idea behind this class is that you can use this to pull out information to be used on your own website(s), or have your own web applications interact with it.
Below are examples for using this class.
- Connecting to FogBugz
- Closing the API connection
- Creating a new issue
- Updating an existing issue
- Reopening an issue
- Resolving an issue
- Closing an issue
- Retrieving an issue
- Searching for an issue
- Using filters
- Retrieving a list of projects
- Retrieving a list of available priorities
- Retrieving a list of available areas for a project
- Retrieving a list of available issue categories
- Retrieving a list of available filters
- Retrieve ticket status
All requests to the FogBugz API must be authenticated. Unfortunately they do this using a plaintext password (so will appear in the server logs on the remote server - something to bear in mind if you host this yourself).
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
This will then give you a new FogbugzIntegration object which can be used to make API calls to retrieve or set data.
$fb->logout();
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue_id = $fb->openTicket('My new issue', 'It does not work - please fix');
The openTicket
function takes as arguments the title of the issue, a description about it, then an optional array for setting additional properties such as project, area, priority, etc.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->updateTicket(1, 'An update to my ticket');
As with openTicket
, the updateTicket
function will take an optional array as it's last parameter for setting other case properties. The only mandatory parameters are for specifying the ticket ID, and the updated message to apply to it. If successful it will return the ID of the ticket.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->reopenTicket(1);
To reopen an issue pass in the ID of the ticket. This too will take an optional array as it's last parameter for setting other case properties. If successful it will return the ID of the ticket.
This will mark a ticket as resolved, but will not close it.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->resolveTicket(1);
If successful it will return the ID of the ticket.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$fb->closeTicket(1);
If successful it will return the ID of the ticket.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->getTicket(1);
Returns a SimpleXML object containing all details for the issue
It is also possible to search for cases by a keyword.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->search('example');
This returns a SimpleXML object containing all details for the issue
Filters defined in FogBugz can also be utilised if they are available to the user who is signed in to the API.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$issue = $fb->setFilter(1);
The result of this is limited to what the user signed into the API has access to.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$projects = $fb->getProjectList();
This will retrieve an array where each element is an array of the project name and owner, and is indexed by the ID of the project. Passing in true
to this function will return the raw SimpleXML output from the API instead.
The result of this is limited to what the user signed into the API has access to.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$priorities = $fb->getAllPriorities();
This will retrieve an array where each element is an array of the priority name and a flag indicating if it's the default, and is indexed by the ID of the priority. Passing in true
to this function will return the raw SimpleXML output from the API instead.
The result of this is limited to what the user signed into the API has access to.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$areas = $fb->getAllAreas(1);
This will retrieve an array where each element is an array of area names indexed by the ID of the area.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$categories = $fb->getAllCategories();
This will retrieve an array where each element is an array of issue categories indexed by the ID of the category.
<a name="getFilters>
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$categories = $fb->getAllFilters();
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$status = getTicketStatus(1);
This will return the specified status as a SimpleXML element.
With FogBugz you have three types of users: normal, virtual, and community. The below example will return normal and virtual users, but will ignore community users.
$fb = new FogbugzIntegration('http://example.fogbugz.com', 'user@example.com', 'password');
$users = $fb->getAllFogbugzUsers(true, true, false);
This will return an array of users indexed by their ID and containing their name and email address.