我希望将一些站点迁移到运行 php55 和 pecl 2 的新服务器。不幸的是,pecl 2 与以前的版本相比有巨大变化,并且提供 0 向后兼容性。
我正在尝试在 pecl 2 中重新创建以下内容,但绝对没有运气,如果有人可以提供建议,我们将不胜感激。
$retVal = http_parse_message(http_post_fields("http://$wgserver/trusted", $params))->body;
干杯。
最佳答案
花了一段时间,但还是以这种方式工作。
//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();
关于php - 将函数从 pecl 1 转换为 pecl 2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24679494/