0

:) I'm trying to send an XML using curl but not as post parameter. what I mean is this.

for example.

the receiving side of that XML won't be able to recieve the XML using $_POST variable.

he will need to use the following code:

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

I want to be able to send an xml string using curl via https.

so the following would be wrong:

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;
}

because here i can use HttpsNoVerify($url,array('xml_file'=>'xml..')); and that will paste it as post parameter. and i want it as post output.

so please I hope i explained myself properly and I explained exactly what I don't want to do.

how can I do what i want to do?

thanks! :)

kfir

1 Answer 1

1

Just directly pass the xml string as second parameter instead of an associative array item,

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

This will eventually call

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

Which will be put in php://input for the remote server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.