you still have a typo in your example:
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
should be
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
..at least i assume it should :-)