Php curl通过SSL作为GET方法或Pt方法发送xml文件

Php curl通过SSL作为GET方法或Pt方法发送xml文件,php,ssl,curl,methods,put,Php,Ssl,Curl,Methods,Put,我需要从服务器接收xml数据。 只允许两种方法将数据发送到服务器“GET”和“PUT” POST方法-不允许 我的代码是 <?php set_time_limit(0); ini_set('display_errors','1'); error_reporting(E_ALL); $url = 'https://url is here..'; $fp = fopen(getcwd() . "/ping.xml", "r+"); //

我需要从服务器接收xml数据。 只允许两种方法将数据发送到服务器“GET”和“PUT” POST方法-不允许

我的代码是

    <?php

    set_time_limit(0);
    ini_set('display_errors','1');

    error_reporting(E_ALL);

    $url = 'https://url is here..';
    $fp = fopen(getcwd() . "/ping.xml", "r+");

// Initialize session and set URL.
    $ch = curl_init();

    //curl_setopt($ch, CURLOPT_URL, $url.'?xml='.$xml); 
    curl_setopt($ch, CURLOPT_URL, $url);    

    //GET
    curl_setopt($ch, CURLOPT_PUT, 1); 
    curl_setopt($ch, CURLOPT_FILE, $fp);
    //curl_setopt($ch, CURLOPT_INFILE, $fp);
    //curl_setopt($ch, CURLOPT_INFILESIZE, filesize(getcwd() . "/ping.xml")); 


    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt( $ch, CURLOPT_SSLVERSION, 3 );  
    curl_setopt($ch, CURLOPT_VERBOSE, '1');

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    curl_setopt($ch, CURLOPT_SSLCERT, getcwd() . "/certs/test_lv.pem");
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "test_lv");

    curl_setopt($ch, CURLOPT_SSLKEY, getcwd() . "/certs/test_lv.key");
    curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "test_lv");

    //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml','correlationId :'.date("y-m-d-h-m-s")));
    curl_setopt($ch, CURLOPT_HEADER, 1);
    // Get the response and close the channel.
    $response = curl_exec($ch);
    echo curl_error($ch);
    print_r($response);
    echo '<br>end';
    curl_close($ch);
?>

我花了一整天的时间连接服务器,现在它可以工作了。 我正在尝试将xml文件作为Put方法发送
Xml文件数据:

<?xml version="1.0" encoding="UTF-8"?>
<Ping>
<Value>Test</Value>
</Ping>

测验
这不起作用,我有以下错误:

HTTP/1.1 100继续HTTP/1.1 500内部服务器错误内容长度:0服务器:Jetty(6.1.21) 结束

答案必须是:
收到pong.xml-s

<?xml version="1.0" encoding="UTF-8"?>
<B4B xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://test.net/valid/hgw-response.xsd">
<Pong from="EE">
<Value>Test</Value>
</Pong></B4B>

测验
谢谢你的建议

另外,我如何通过GET方法发送xml文件..我正在尝试这样做

$xml = '<?xml version="1.0" encoding="UTF-8"?>
        <Ping>
            <Value>Test</Value>
        </Ping>';

curl_setopt($ch, CURLOPT_URL, $url.'?xml='.$xml);
$xml='1!'
测验
';
curl_setopt($ch,CURLOPT_URL,$URL'.?xml='.$xml);
这对我来说不太管用