我試過閱讀古文字文件,但我無法將這個問題包裹起來。將此捲曲轉換爲古怪文字
我想用狂飲,而不是捲曲以下:
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);
我試過,但我還是新在這...:
$client = new Client($this->url);
$response = $client->get($xml);
除了你已經得到的答案,你可能會發現它有助於瞭解PHP中的HEREDOC字符串類型:http://php.net/language.types.string.php#language.types.string.syntax.heredoc – hakre