public function testErrorHandlingFromCurl() { $mock_request_options = prepare_options_for_clever(); try { $response = request_from_clever("httpl://*****:*****@cURL failure@", $e->getMessage()); } }
/** * Uses the specified bearer token to retrieve the /me response for the user * @param string $bearer_token The string value of a user's OAuth 2.0 access token * @param array $options Options used for Clever API requests * @throws Exception if the /me API response cannot be retrieved * @return array $oauth_response Hash of Clever's response when identifying a bearer token's owner */ function retrieve_me_response_for_bearer_token($bearer_token, array $options) { $request_options = array('method' => 'GET', 'bearer_token' => $bearer_token); $response = request_from_clever($options['clever_api_me_url'], $request_options, $options); // Evaluate if the response is successful if ($response && $response['response_code'] && $response['response_code'] == '200') { $oauth_response = $response['response']; return $oauth_response; } else { // Handle condition when /me response cannot be retrieved for bearer token throw new Exception("Could not retrieve /me response for bearer token."); } }