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?
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()
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.