使用php-ccurl发送xml字符串,但不作为post参数


sending xml string using php curl but not as post parameter

:(我正在尝试使用curl发送一个XML,但不是作为post参数。我的意思是这个。

例如。

该XML的接收端将不能使用CCD_ 1变量接收XML。

他将需要使用以下代码:

    $xmlStr=null;
    $file=fopen('php://input','r');
    $xmlStr=fgets($file);

我希望能够通过https使用curl发送一个xml字符串。

因此以下内容是错误的:

public static function HttpsNoVerify($url,$postFields=null,$verbose=false) {
    // Initialize session and set URL.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    // Set so curl_exec returns the result instead of outputting it.
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    if ($postFields !=null) {
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    }
    if ($verbose) {
        curl_setopt($ch, CURLOPT_VERBOSE, 1);
    }
    // Get the response and close the channel.
    $response = curl_exec($ch);
    curl_close($ch);
    return $response;
}

因为在这里我可以使用HttpsNoVerify($url,array('xml_file'=>'xml..'));将其粘贴为post参数。我想把它作为后期输出。

所以我希望我能正确地解释我自己,并准确地解释了我不想做的事情。

我该怎么做我想做的事?

谢谢!:(

kfir

只需直接传递xml字符串作为第二个参数,而不是关联数组项

HttpsNoVerify($url, 'xml ..');

这将最终调用

curl_setopt($ch, CURLOPT_POSTFIELDS, "xml ...");

它将被放入远程服务器的php://input中。