2
與捲曲的查詢,像這樣的,做工精細:HTTP_Request2 POST參數被忽略?
curl -XPOST -H "Content-Type: application/json" -d '{"query":"porges","start":0,"rows":10,"lang":"ENGLISH"}' http://localhost:8080/services/rest/index/z56508/search/field/search
我我的情況,我得到11次命中那裏。但是,當我嘗試將其轉換爲HTTP_Request2時,該調用將返回數據庫中的所有匹配。
我已經看過Http_Request2 POST request not working到這裏寫代碼:
require_once 'HTTP/Request2.php';
$url = "http://localhost:8080/services/rest/index/z56508/search/field/search";
$data = array("query"=>"porges","start"=>"0","rows"=>"10","lang"=>"ENGLISH");
$r = new HTTP_Request2($url);
$r->setHeader('Content-Type', 'application/json;charset=UTF-8');
$r->setMethod(HTTP_Request2::METHOD_POST)
->addPostParameter($data);
$response = $r->send();
$body = $response->getBody();
echo $body;
我在做什麼錯?好像"query" => "porges"
被忽略,但爲什麼?