I have a piece of code which written in CakePHP for sending a HTTP Post Request
to a URI and get response.
I don't know CakePHP and need to change that to Guzzle style for sending that HTTP Post Request
.
Here is the CakePHP code :
private static function sendRequest() {
App::uses('HttpSocket', 'Network/Http');
try {
$HttpSocket = new HttpSocket();
return trim($HttpSocket->post(self::$webserviceUri, self::$requestData, [
'header' => ['Content-Type' => 'text/xml'],
'auth' => ['method' => 'Basic', 'user' => self::$username, 'pass' => self::$password]
]));
} catch (SocketException $e) {
CakeLog::write('request_error', 'Request Error: '. $e->getMessage());
return false;
}
}
The Main Goal Is:
How can I send exactly a such HTTP Post Request( above code ) by using Guzzle?
Any helps would be great appreciated.
P.S: I'm using Guzzle 6.2