1

I am using cURL through a PHP file to create a fogbugz case using values I will pull from the current ticket. Right now I am only trying to display the token received when a user logs into fogbugz and I am not getting any values from the response.

Here is the code I am using in my PHP file:

<?php

$user = "USERNAME";
$password = "PASSWORD";
$url = "fogbugz.spllc.local/api.asp?";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_PROXYUSERPWD, "[$user]:[$password]");

if (false === ($output = curl_exec($ch)))
{
        print "error" . curl_error($ch);
        die("ERROR" . curl_error($ch));
}
else if (200 !== (int)curl_getinfo($ch, CURLINFO_HTTP_CODE))
{
        print "200";
        die("200");
}

print curl_exec($ch);

curl_close($ch);

?>

Can someone help point me in the right direction?

Thanks

1 Answers1

0

When you read the documentation on http://fogbugz.stackexchange.com/fogbugz-xml-api you will find you have to send a get or post request. Something like shown below should work:

$ch = curl_init('http://fogbugz.spllc.local/api.asp?cmd=logon&email=John%20Hancock&password=BigMac');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);

also take a look at: https://github.com/there4/fogbugz-php-api

Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224
  • @Perry - I have php 5.4.11 and curl support enabled, cURL information is 7.19.7. – tylerimplom Apr 23 '13 at 13:29
  • @hakre - I was looking at some other php that used it this way so I gave it a try. – tylerimplom Apr 23 '13 at 13:39
  • I tried that code and printed the output with no success. I copy and pasted my url with username and password into my browser and it brings back my token. Is there some reason that the url will give me my token when pasted in a browser but not through curl? – tylerimplom Apr 23 '13 at 13:40
  • The thing that is really confusing me is that when I use cURL to try just the base link("http://fogbugz.splls.local"), It will return the welcome/login page for fogbugz. But if I try to go farther and use the logon command it doesn't return anything. – tylerimplom Apr 23 '13 at 15:02