I need to post to an application with one of the data is xml
string. To pass the &
and special characters
, the application suggests to curl post
with -d option
.
How do pass -d option
with PHP curl
?
I need to post to an application with one of the data is xml
string. To pass the &
and special characters
, the application suggests to curl post
with -d option
.
How do pass -d option
with PHP curl
?
The -d
flag is the POST Data flag.
To send POST fields using curl via PHP do the following:
$ch = curl_init( $url );
# Setup request to send xml via POST.
$payload = "xmlRequest=" . urlencode($input_xml);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
You'll get your XML in the "xmlRequest" on the other side.