cURL没有带回价值

时间:2013-04-19 19:56:35

标签: php curl fogbugz

我正在使用cURL通过PHP文件创建一个fogbugz案例,使用我将从当前票证中提取的值。现在我只是试图显示当用户登录fogbugz时收到的令牌,而我没有从响应中获取任何值。

以下是我在PHP文件中使用的代码:

<?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);

?>

<?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); ?>

有人可以帮助我指出正确的方向吗?

由于

1 个答案:

答案 0 :(得分:0)

当您阅读http://fogbugz.stackexchange.com/fogbugz-xml-api上的文档时,您会发现必须发送获取或发布请求。 下面显示的内容应该有效:

$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);

还要看一下:https://github.com/there4/fogbugz-php-api