相关疑难解决方法(0)

将此cURL转换为Guzzle

我试过阅读Guzzle文档,但我无法解决这个问题.

我想使用Guzzle代替cURL以下内容:

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);
Run Code Online (Sandbox Code Playgroud)

我试过这个,但我还是新来的......:

$client …
Run Code Online (Sandbox Code Playgroud)

php xml xmlhttprequest guzzle

8
推荐指数
1
解决办法
6987
查看次数

标签 统计

guzzle ×1

php ×1

xml ×1

xmlhttprequest ×1