Created
July 5, 2010 15:00
-
-
Save gasi/464432 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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