将函数从pecl 1转换为pecl 2

时间:2014-07-10 14:40:59

标签: php pecl

我希望将一些站点移动到运行php55和pecl 2的新服务器上。不幸的是,pecl 2与之前版本相比发生了巨大变化,并提供了0向后兼容性。

我正试图在pecl 2中重新创建以下内容而绝对没有运气,如果有人能提出建议,我将非常感激。

$retVal = http_parse_message(http_post_fields("http://$wgserver/trusted", $params))->body;

干杯。

1 个答案:

答案 0 :(得分:2)

花了一段时间,但让它以这种方式工作。

//Set the params for posting the relevant info to the server
$params = array(
  'username' => $user,
  'target_site'=>$targetSite
);

//Create the initial request
$request = new http\Client\Request("POST","http://$wgserver/trusted");
//Add the params to the body
$request->getBody()->append (new http\QueryString($params));
//Set the client
$client = new http\Client;
//Make the POST
$client->enqueue($request)->send();
//Capture the response
$response = $client->getResponse($request);
//Extract the body of the response (since that's what I need for this example)
$bod = $response->getBody();