Hi dears , i want to call a thousand request in guzzle once time and ensure each callback correct
i have the error
require_once "vendor/autoload.php"; use GuzzleHttp\Client; $client = new Client([ // Base URI is used with relative requests 'base_uri' => 'https://api.ma.io', // \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath() ]); $response = $client->request('POST', '/tok/gen, [ 'verify' => false, 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded' ], 'json' => [ 'username' => 'email@example.com', 'password' => 'pass123' ] ]);
$url. Is a bug on Guzzle or I'm doing something wrong?
$curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS => $string_params, CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded' ), )); $response = curl_exec($curl); curl_close($curl); $client = new Client(); $client->request('POST', $url, [ 'form_params' => $array_params ]);
Ciao Pietro, ensure the request made with Guzzle is the same as the curl one and then try again...
@bizmate thanks for your reply, maybe i'm wrong but
CURLOPT_RETURNTRANSFER => true, <-- Not relevant for Guzzle CURLOPT_ENCODING => '', <-- Act with default like Guzzle CURLOPT_MAXREDIRS => 10, <-- Follow redirection are enable by default on Guzzle ( I'm calling a direct endpoint I don't have any redirection) CURLOPT_TIMEOUT => 0, <-- Same as Guzzle default CURLOPT_FOLLOWLOCATION => true, <-- The endpoint don't return any Location heade CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, <-- HTTP 1.1 is Guzzle default CURLOPT_CUSTOMREQUEST => 'POST', <-- Specified in request CURLOPT_POSTFIELDS => $string_params, <-- Specified as array CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'), <-- Set because `form_params` specified (?)
I also tried without antivirus but it don't resolve the problem
I'm starting to think that is a Guzzle bug and maybe i can move this to Github issues
->getConfig()method on my client to retrieve cookies for later use (essentially maintaining session over different program calls). Since this method is getting deprecated, is there an alternative way to grab the cookie jar from the client? I tried checking the documentation, but the website is timing out for me.