um_url = $um_url; $this->cookiejar = $cookiejar; } public function get_userinfo($username, $password) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->um_url.'/auth'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiejar); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'action'=>'login', 'username'=>$username, 'password'=>$password)); curl_exec($ch); $auth_status=curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($auth_status!==200) { // couldn't log in return $auth_status; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $this->um_url.'/users/'.$username.'.json'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiejar); curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiejar); $json_str = curl_exec($ch); $json_arr = json_decode($json_str, true); return $json_arr[0]; } }