Issue
I want perform a CURL request with parameters and values by using GET method but I don't want to mix them before passing to curl like it is in the string:
www.example.com/index.php?parameter=value
I would like to pass separate url string and query string or at best url string + an array of parameters and values to CURL with letting to know CURL that I want to use GET method (CURLOPT_HTTPGET=TRUE).
Is there any CURLOPT_POSTFIELDS equivalent for GET method?
Solution
Use the function http_build_query()
to create the query string from an associative array.
$query = http_build_query($params);
curl_setopt($ch, CURLOPT_URL, "www.example.com/index.php?$query");
Answered By - Barmar Answer Checked By - Timothy Miller (WPSolving Admin)