Hi I have api with the following requirement.
Send post data like that:
data[email] : test@test.com
data[firstName] :first
data[lastName] : last
data[country] :DE
How can I send it via curl?
Hi I have api with the following requirement.
Send post data like that:
data[email] : test@test.com
data[firstName] :first
data[lastName] : last
data[country] :DE
How can I send it via curl?
See this answer: How do I use arrays in cURL POST requests
if you already have the array $data:
$field_string = http_build_query($data);
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
...