Created
October 29, 2015 14:31
-
-
Save nielsenrc/4b944b838b26b9873eec to your computer and use it in GitHub Desktop.
PHP Function for Authenticated Calls to Ziptastic
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 | |
function callZiptastic($zipcode, $referrerDomain, $apiKey) { | |
$url = "https://zip.getziptastic.com/v3/US/" . $zipcode; | |
$options = array( | |
CURLOPT_URL => $url, | |
CURLOPT_RETURNTRANSFER => 1, | |
); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'x-referrer: ' . $referrerDomain , | |
'x-key: ' . $apiKey, | |
)); | |
curl_setopt_array($ch, $options); | |
$response = curl_exec($ch); | |
curl_close ($ch); | |
return $response; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment