Skip to content

Instantly share code, notes, and snippets.

@gasi
Created July 5, 2010 15:00
Show Gist options
  • Save gasi/464432 to your computer and use it in GitHub Desktop.
Save gasi/464432 to your computer and use it in GitHub Desktop.
// cURL: http://php.net/manual/en/book.curl.php
// cURL Options: http://www.php.net/manual/en/function.curl-setopt.php
// @param $url URL of the request, e.g. https://www.sandbox.paypal.com/cgi-bin/webscr
// @param $data URL encoded request data as array, e.g. $data = array('cmd' => '_notify-validate');
function urlopen($url, $data)
{
$curl_handler = curl_init();
$options = array(CURLOPT_URL => $url,
CURLOPT_FAILONERROR => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 3,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data)
);
curl_setopt_array($curl_handler, $options);
$result = curl_exec($curl_handler);
curl_close($curl_handler);
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment