Skip to content

Instantly share code, notes, and snippets.

@sudipto-me
Created October 22, 2018 13:53
Show Gist options
  • Save sudipto-me/bc8ef1e94c122eb5d323a29c6fccefe2 to your computer and use it in GitHub Desktop.
Save sudipto-me/bc8ef1e94c122eb5d323a29c6fccefe2 to your computer and use it in GitHub Desktop.
function post_to_url($data) {
$fields = '';
foreach($data as $key=>$value){
if(!empty($value)){
$fields .= $key .'='.$value.'&';
}
}
$substr = substr($fields,-1);
if(substr($fields,-1)=='&') {
$fields = substr($fields,0,-1);
}
$post = curl_init();
curl_setopt($post, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($post,CURLOPT_URL,'https://hooks.zapier.com/hooks/catch/751765/qq03pg/');
curl_setopt($post,CURLOPT_POST,count($data));
curl_setopt($post,CURLOPT_POSTFIELDS,$fields);
curl_setopt($post,CURLOPT_RETURNTRANSFER,1);
$result = curl_exec($post);
curl_close($post);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment