<html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> <hr><center>nginx</center> </body> </html>

$client = new GuzzleHttp\Client;
$response = $client->request("POST", "http://www.jgggbbs.cn/member.php?mod=logging&action=login&loginsubmit=yes&handlekey=login&loginhash=LRTTI&inajax=1", array(
    "form_params" => array(
        "username"=>"test",
        "password"=>"fwefwegweg"
    ),
    "allow_redirects" => true,
    "headers" => [
        "User-Agent" => "Mozilla/5.0 (Windows NT 10.0; ) Gecko/20100101 Firefox/61.0",
        "content-type" => "application/x-www-form-urlencoded",
        "cache-control"      => "no-cache"
    ]
));
print_r($response->getBody()); //

use PHP GuzzleHttp to log in to a forum, no matter whether the user name and password are wrong or not, and no matter whether the submitted parameters are wrong or not, even if there is an error, the site will return a text prompt for an error, but now I can"t get any returned text, what"s the matter?

the following is to use php curl to send the request, which can get the returned result (again, regardless of whether the login is successful or not, as long as the result is returned):

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://www.jgggbbs.cn/member.php?mod=logging&action=login&loginsubmit=yes&handlekey=login&loginhash=LRTTI&inajax=1",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "username=test&password=test",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "content-type: application/x-www-form-urlencoded"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error -sharp:" . $err;
} else {
  echo $response; //
}
Php
Mar.28,2021

json_decode($response->getBody()->getContents(), true)

look at the status code first

$response->getStatusCode();

normal $response- > getBody () returned stream object

Menu