I am sending a request from the client using GuzzleHttp\Client to a page on another port that is serving as a server like
use SL\Controllers\LoginController;
use SL\FileHelper;
use GuzzleHttp\Client;
require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . "config/config.php";
$client = new Client();
$response = $client->request('get','http://myip:75/src/LoginVerification.php?username=asd&password=asd');
The request is served on the page
require_once(__DIR__ . '/../config.php');
use Moodle\Manager\UserManager;
use GuzzleHttp\Psr7\Response;
$userManager = new UserManager();
$user;
$username = $_GET["username"];
$password = $_GET["password"];
$isLogin = $userManager->verifyLogin($username, $password, $user);
if($isLogin)
$body = "yahoo";
else
$body = "oooops";
$status = 201;
$headers = ['Content-Type' => 'application/json'];
$protocol = '1.1';
$response = new Response($status, $headers, $body, $protocol);
return $response;
please ignore the password passing in GET as my main focus here is to send requests and get responses.
After the request is served on the server and response that I made is as below
phrases:array(58)
reasonPhrase:"Created"
statusCode:201
headers:array(1)
headerNames:array(1)
protocol:"1.1.1"
stream:GuzzleHttp\Psr7\Stream
stream:resource id='10' type='stream'
size:null
seekable:true
readable:true
writable:true
uri:"php://temp"
But what is received is this
headerNames:array(9)
headers:array(9)
statusCode:200
reasonPhrase:"OK"
phrases:array(58)
protocol:"1.1"
headerNames:array(9)
headers:array(9)
phrases:array(58)
reasonPhrase:"OK"
statusCode:200
stream:resource id='4' type='stream'
size:null
seekable:true
readable:true
writable:true
uri:"php://temp"
It is not the same response that I had created.