Created
October 22, 2018 13:53
-
-
Save sudipto-me/bc8ef1e94c122eb5d323a29c6fccefe2 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
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