How send post request with x www form urlencoded body in php?
I need to post this Show asked Sep 20, 2013 at 9:32
Saravanan M PSaravanan M P 5211 gold badge7 silver badges12 bronze badges
answered Sep 20, 2013 at 9:36
Shakti PatelShakti Patel 3,6424 gold badges21 silver badges29 bronze badges 6
answered May 5, 2017 at 13:34
Try something like:
answered Sep 20, 2013 at 9:42
anupamanupam 7365 silver badges11 bronze badges 0 Not the answer you're looking for? Browse other questions tagged php api curl php-5.3 or ask your own question.With application-x-www-form-urlencoded post in cURL, we should use http_build_query to generate URL-encode data and put them in CURLOPT_POSTFIELDS. Example
Use itThe following is an example of sending an array.
Output
The request header Content-ype is automatically set to application/x-www-form-urlencoded. How send post request with X www form Urlencoded body PHP?“php curl post application/x-www-form-urlencoded” Code Answer. //this send application/x-www-form-urlencoded.. function httpPostXform($url, $data) {. $curl = curl_init($url);. curl_setopt($curl, CURLOPT_POST, true);. curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));. How do you pass X www form Urlencoded parameters in curl?To post form data with Curl, you can use one of two command-line parameters: -F (--form) or -d (--data). The -F command-line parameter sends form data with the multipart/form-data content type, and the -d command-line parameter sends form data with the application/x-www-form-urlencoded content type.
What is Curlopt_postfields?CURLOPT_POSTFIELDS. The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'.
|