3

I am using curl to post XML to a webservice. The code is below:

exec("/usr/bin/curl -s -m 120 -d  \"$xml\" $URL -L", $return_message_array, $return_number);

I want to add this custom header to it:

$headers = array(            
        "Content-type: application/soap+xml; charset=utf-8",
        "SOAPAction: http://loantree.com/webservices/InsertLead",
    );

I have tried:

exec("/usr/bin/curl -s -m 120 -H $headers -d  \"$xml\" $URL -L", $return_message_array, $return_number);

But that just returns the page I'm trying to post to. Does anyone know how I can achieve this?

1 Answer 1

2

Headers for curl are set with the -H option, which can be used multiple times:

curl -H "Header-1: Value" -H "Header-2: Value" http://example.com

Note: If installed, PHP has a curl library. So you don't have to use exec().

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

1 Comment

Great. Welcome to StackOverflow.

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.