我在使用 freebase MQL 登录服务时遇到问题。我正在发出一个 post 请求,然后 freebase api 应该发回标头,然后我将分析并从中获取信息。
但我得到的唯一标题是HTTP/1.0 200 OK
代码
class myFreebaseClass {
....
function doLogin() {
echo $uri = "http://".$this->config['apiSandboxHost'].'/'.$this->config['apiLoginPath'].'username='.$this->config['apiLoginUser'].'&password='.$this->config['apiLoginPass'];
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, array(&$this,'readHeader'));
$output = curl_exec($ch);
curl_close($ch);
}
function readHeader($ch, $string)
{
echo "Header: ".$string."<Br />";
if(strpos($string, 'Set-Cookie') !== false) {
$this->authCookies[] = str_replace('Set-Cookie: ', '', $string);
}
return true;
}
}
输出
http://sandbox.freebase.com/api/account/login?username=dXXXXX&password=XXXX
Header: HTTP/1.0 200 OK
我究竟做错了什么?我是否错误地获取标题?
提前致谢!