Created
March 20, 2014 23:27
-
-
Save dpawluk/9676269 to your computer and use it in GitHub Desktop.
Function that uses curlWrap to take an email input and returns a user's id.
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 | |
require_once('curlwrap.php'); | |
function getUserIdByEmail($email) { | |
$query = curlWrap('/search.json?query=type:user%20email:' . $email ,'',GET); | |
$results_array = $query->results; | |
$results_length = count($results_array); | |
if($results_length == 1){ | |
echo "we found a single match, good stuff!\n User ID: "; | |
return $results_array[0]->id; | |
} | |
elseif($results_length == 0) { | |
echo "no results found!"; | |
}else { | |
echo "we found more than one user with that email! The Sky is falling!"; | |
} | |
} | |
$users_id = getUserIdByEmail("some_email@domain.com"); | |
echo $users_id; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment