I'm trying to create a query string from POST data that I already have set as the variables $email and $ip. It needs to be application/x-www-form-urlencoded
could I use http_build_query? A little rusty here. I just need help pulling the variables and adding them to the string to POST.
Here is the section I'm working on. (Just using this for testing to see responses)
function coSponsorPush2($email) {
global $ip;
global $email;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => '#',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => http_build_query(['email' => $email, 'ip_address' => $ip]),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/x-www-form-urlencoded'
),
));
$resp = curl_exec($curl);
curl_close($curl);
}
Thank you!