Created
June 2, 2016 17:26
-
-
Save bwente/56945b22056d70fd44348b53d50d0faf to your computer and use it in GitHub Desktop.
Send search queries to Zapier webhook
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
<?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