public static function authenticate($api_key, $api_secret, $captcha, $captcha_token) { try { $api = new GoogleUtilityClient($api_key, $api_secret, 'HOSTED_OR_GOOGLE', $captcha, $captcha_token); $api->authenticate(); return TRUE; } catch (GoogleUtilityClientException $e) { switch (GoogleLoginChallenge::get_error($e->getCode())) { case 'CaptchaRequired': $captchaException = new GoogleCaptchaChallengeException($e->getMessage(), $e->getCode()); $captchaException->captcha_url = $api->auth_response['CaptchaUrl']; $captchaException->captcha_token = $api->auth_response['CaptchaToken']; throw $captchaException; } throw new GoogleDomainException($e->getMessage(), $e->getCode()); } }