Skip to content

Instantly share code, notes, and snippets.

@dpawluk
Created March 20, 2014 23:27
Show Gist options
  • Save dpawluk/9676269 to your computer and use it in GitHub Desktop.
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.
<?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