致命错误:找不到类'http \ Client'

时间:2017-12-09 10:47:53

标签: php

我正在尝试使用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();

0 个答案:

没有答案