Ho provato a leggere i documenti di Guzzle ma non riesco a risolvere il problema.Conversione di questo cURL per Guzzle
voglio usare Guzzle invece di cURL per i seguenti:
protected $url = 'https://secure.abcdef.com/cgi/xml_request_server.php';
$xml = "<ABCRequest>\n";
$xml .= "<Authentication>\n";
$xml .= "<ABLogin>$this->gwlogin</ABLogin>\n";
$xml .= "<ABKey>$this->gwkey</ABKey>\n";
$xml .= "</Authentication>\n";
$xml .= "<Request>\n";
$xml .= "<RequestType>SearchABC</RequestType>\n";
$xml .= "</Request>\n";
$xml .= "</ABCRequest>\n";
$header = "POST $this->url HTTP/1.1\n";
$header .= "Host: domain.com\n";
$header .= "Content-Length: ".strlen($xml)."\n";
$header .= "Content-Type: text/xml; charset=UTF8\n";
$header .= "Connection: close; Keep-Alive\n\n";
$header .= $xml;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->url);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
$response = curl_exec($ch);
curl_close($ch);
Ho provato questo, ma io sono ancora nuovo a questo ...:
$client = new Client($this->url);
$response = $client->get($xml);
Oltre alla risposta che hai già potresti trovare utile conoscere Tipo di stringhe HEREDOC in PHP: http://php.net/language.types.string.php#language.types.string.syntax.heredoc – hakre