Created
February 2, 2015 15:41
-
-
Save joeydsmith/aa90d48fb56a32a8e6d7 to your computer and use it in GitHub Desktop.
This file contains 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
public function fetchUrl_POST($url, $fields){ | |
//open connection | |
$ch = curl_init(); | |
foreach($fields as $key=>$value) { | |
$fields_string .= $key.'='.$value.'&'; | |
} | |
rtrim($fields_string, '&'); | |
//set the url, number of POST vars, POST data | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_VERBOSE, 0); | |
curl_setopt($ch, CURLOPT_POST, count($fields)); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); | |
//execute post | |
$feedData = curl_exec($ch); | |
curl_close($ch); | |
return $feedData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment