Skip to content

Instantly share code, notes, and snippets.

@rickfillion
Created February 10, 2011 04:59
Show Gist options
  • Save rickfillion/819975 to your computer and use it in GitHub Desktop.
Save rickfillion/819975 to your computer and use it in GitHub Desktop.
<?php
$host="https://bodega.fogbugz.com/api.asp";
$user="rick@madefresh.ca";
$password = "********";
$query = 'project:"Bodega Application" milestone:"1.4.0" status:"Active"';
$cols = "ixBug";
$tokenCommand = "curl \"$host?cmd=logon&email=$user&password=$password\" | perl -ne 'print if s/.*\\[CDATA\[(.*)\\]\\].*/\\1/'";
$token = shell_exec($tokenCommand);
$query = urlencode($query);
$queryCommand = "curl \"$host?cmd=search&q=$query&cols=$cols&token=$token\"";
$queryResult = shell_exec($queryCommand);
$regex = "/cases count=\"(\d+)\"/";
preg_match($regex, $queryResult, $matches, PREG_OFFSET_CAPTURE);
$totalCount = $matches[1][0];
echo "<?xml version='1.0' encoding='UTF-8'?>\n";
?>
<root>
<item>
<value><?= $totalCount?></value>
<text></text>
</item>
</root>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment