我正在尝试使用HttpClient调用Rest API但是获取 错误“致命错误:未在”
中找到“http \ Client”类PHP代码:
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->addForm(NULL, array(
array(
'name' => 'attachment',
'type' => null,
'file' => REPORTPATH . $_SERVER['HTTP_DISTRIBUTORAPIKEY'] . "\\08122017123602.zip",
'data' => null
)
));
$request->setRequestUrl('http://192.168.1.55/api/upload');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'cache-control' => 'no-cache',
'foldername' => '1HUBH',
'distributorcode' => '1HUBH'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();