首页 > 解决方案 > 在 API Guzzle HTTP 中获取 Laravel Http 中的私有属性

问题描述

我想在调用方法时将响应数据(如私有属性)存储到变量中

use Illuminate\Support\Facades\Http;

 public function myMethod(){
        $result = [];
        $response = Http::asForm()->withHeaders([
         'origin' => 'https://example.com',
         'content-type' => 'application/x-www-form-urlencoded',
         'referer' => 'https://example.com',
     ])->post('https://example.com', [
         'email' => 'example@gmail.com',
         'pass' => 'mypassword',
         'login' => 'Log+In',
         'withCredentials' => true, 
     ]);

     $result = $response;
     }

结果

在此处输入图像描述


但我不能在这个结果中使用键

标签: phplaravelapihttpguzzle

解决方案


推荐阅读