You'll need to chante this line:
curl_setopt($ch, CURLOPT_POST, 1);
to this
curl_setopt($ch, CURLOPT_POST, 0);
comment out this line:
curl_setopt($ch, CURLOPT_POSTFIELDS, implode('&', $data));
And you'll need to move the CURLOPT_URL line:
curl_setopt($ch, CURLOPT_URL, $url);
to after those foreach loops that perform the parsing of the variables...and change it too...maybe something like this:
curl_setopt($ch, CURLOPT_URL, $url . '?' . implode('&', $data));