Skip to content

Instantly share code, notes, and snippets.

@bwente
Created June 2, 2016 17:26
Show Gist options
  • Save bwente/56945b22056d70fd44348b53d50d0faf to your computer and use it in GitHub Desktop.
Save bwente/56945b22056d70fd44348b53d50d0faf to your computer and use it in GitHub Desktop.
Send search queries to Zapier webhook
<?php
$timestamp = date('m/d/Y h:i:s');
$ip = $_SERVER['HTTP_CLIENT_IP']?:($_SERVER['HTTP_X_FORWARDED_FOR']?:$_SERVER['REMOTE_ADDR']);
// post to webhook url
$url = $scriptProperties['webhook'];
if (isset($url)) {
$postvars = 'timestamp=' . $timestamp . '&ip=' . $ip . '&search=' . $search;
$ch = curl_init($url);
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $postvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
}
return true;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment