Send array with internal array via CURL PHP

Asked

Viewed 47 times

-1

The following Array is sent to a API through a POST using CURL:

$content = array(
  'name' => $_POST['name'], // Recebe String de um <form>
  'price' => $price,
  'stock' =>$stock,
  'link' => $_POST['link'], // Recebe Array de um <form>
  'picname' => $img_name
);

CURL responsible for sending:

  curl_setopt( $ch, CURLOPT_POSTFIELDS, $content );

My doubt is, how to send along to $content to $_POST['link'] received by a <form>?

1 answer

0

I solved the bug using http_build_query() in CURl, in this way:

curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($content) );

Browser other questions tagged

You are not signed in. Login or sign up in order to post.