d3no d3no - 5 months ago 72
PHP Question

Guzzle6 error Invalid resource type: array when send a GuzzleHttp\Psr7\Request

I am trying to send a code by using GuzzleHttp\Psr7\Request,somehow I get error Invalid resource type: array, the following is my codes

$params = ["name"=>"myName","id"=>"myId"];
$client = new Client();
$request = new Request('PUT','https://api.hitbox.tv/media/live/myName?authToken=myToken',["content-type"=>'application/json'],["json"=>$params]);

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

I'm following this guide.


If you want to use JSON in the request, just create it with json_encode():

$request = new Request(
    ["content-type" => 'application/json'],