4

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.

Community
  • 1
  • 1
d3no
  • 121
  • 1
  • 3
  • 12

1 Answers1

9

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

$request = new Request(
    'PUT',
    'https://api.hitbox.tv/media/live/myName?authToken=myToken',
    ["content-type" => 'application/json'],
    json_encode($params)
);
Alexey Shokov
  • 4,775
  • 1
  • 21
  • 22