Thinkphp5如何使用http2发送请求

浏览:154 发布日期:2022/12/01 分类:ThinkPHP5专区 关键字: 请求 http2
$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->addForm([
'image_type' => 'message'
], [
[
'name' => 'image',
'type' => '',
'file' => [
'C:\\Users\\Administrator\\OneDrive\\图片\\QQ图片20220214093200.jpg'
],
'data' => [
'C:\\Users\\Administrator\\OneDrive\\图片\\QQ图片20220214093200.jpg'
]
]
]);

$request->setRequestUrl('https://open.feishu.cn/open-apis/im/v1/images');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders([
'Authorization' => 'Bearer t-g104c1c5IMURO4XZHAEW2LT3CDXZ4AW77PYFWGF5'
]);

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
运行报错:致命错误: Class 'http\Message\Body' not found
最佳答案
评论( 相关
后面还有条评论,点击查看>>