0
我有一个需要HTTP/Request2.php的API。API HTTP/Request2.php到CURL
(Apache的HTTP客户端的HTTP组件(http://hc.apache.org/httpcomponents-client-ga/)
我可以使用卷曲取而代之的,是有什么办法不使用这个组件?
这里是API代码
<?php
require_once 'HTTP/Request2.php';
$request = new Http_Request2('http://ww');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
没有足够的信息来给出良好的方向。理论上你应该可以使用cURL来做到这一点,因为在一天结束的时候,你可能正在做的就是形成一个HTTP请求。现在是否重写代码以使用cURL是完全不同的问题。 –
我用代码更新我的问题 – Markos