Skip to content

Instantly share code, notes, and snippets.

@joeydsmith
Created February 2, 2015 15:41
Show Gist options
  • Save joeydsmith/aa90d48fb56a32a8e6d7 to your computer and use it in GitHub Desktop.
Save joeydsmith/aa90d48fb56a32a8e6d7 to your computer and use it in GitHub Desktop.
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