Created
January 11, 2013 07:24
-
-
Save ankitnetwork18/4508692 to your computer and use it in GitHub Desktop.
curl: php function to post curl request to url with post data
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
/** | |
* This functions Sends Post curl request | |
* @param string $url url where posts request is send | |
* @param array $post_data array containing post data with key value pairs | |
* @return string | |
*/ | |
function post_curl($url, $post_data){ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment