我正在尝试通过Laravel控制器使用Laravel将图像上传到Imgur,但是,我已经创建了上传,但是我不知道如何获取响应结果的特定ID。谢谢。
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.imgur.com/3/image', [
'headers' => [
'authorization' => 'Client-ID ' . 'my_id',
'content-type' => 'application/x-www-form-urlencoded',
],
'form_params' => [
'image' => base64_encode(file_get_contents($request->file('image')->path()))
],
]);
echo $result = response()->json(json_decode(($response->getBody()->getContents())));
答案 0 :(得分:1)
WriteResult
可用于访问对象属性。签出以下示例:
->