I'm getting crazy with PHP curl and query string against Magento 2 REST Api. I have the following query:
http://mystore/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=10
coping and pasting it in the browser it works fine. If I use PHP and curl like in this example:
$curl = curl_init("http://mystore/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=category_id&searchCriteria[filter_groups][0][filters][0][value]=10");
...
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
...
]);
return curl_exec($curl);
Magento return an "Invalid signature" error. I found the problem, is the encoding of "&" character, but I tried using urlencode() or htmlentities(), I cannot find a solution. It works only substituting "&" with "& amp;" (without space), but the query is not correctly interpreted. Which is the correct way to send the query string using PHP curl?