1

I've tried to create an HTTP request via the Guzzle libary, but it outputs the error

Cannot use object of type stdClass as array

$body = array("foo" => "bar");

$response = self::$client->request("POST", $url, array(
    "form_params" => $body,
    "auth" => $auth
));

I tried the following and it worked:

$response = self::$client->request("POST", $url, array(
    "form_params" => array("foo" => "bar"),
    "auth" => $auth
));

Sadly this isn't the solution I'm searching for, because I want to use it in a generic method, where I transfer the form parameters from another class.

P.S. I've found the following post, but it got obvious problems that I don't have in my code: Guzzle form_params not accepting array

RatzzDE
  • 11
  • 1
  • There are absolutely no differences between your two snippets. There must be something else you're not sharing. Which line is that error is even occurring on? – Jeto Nov 02 '20 at 21:06
  • After some debugging I found out that it is because of the value I use. I guess it's too long? How can I fix this, because I need to use the value like that. 0,3.1,0,1,11,2530734355,0,-1,-1,0,-1,-1,0,-1,-1,2,106,5,2,259,77,1,0,0,1,1,1,902248182,11,1,0,0,0,1,1920,1080,2,0,85,0,2454050980|97,1733,110,65|100,83,81,68|119,148,87,87|97,2,48,65|100,63,83,68|97,104,78,65|119,16,68,87|100,85,70,68|97,98,66,65|119,4,84,87|100,91,51,68 – RatzzDE Nov 03 '20 at 09:52

0 Answers0