public String XAuth(String username, String password)
	{
		URL url;
		try {
			url = new URL("http://fanfou.com/oauth/access_token");
		} catch (MalformedURLException e) 
		{
			setLog(e.getMessage());
			return null;
		}
		long timestamp = System.currentTimeMillis() / 1000;
		long nonce = System.nanoTime();
		String params;
		String authorization;
		params = "oauth_consumer_key=" + consumer_key
				+ "&oauth_nonce=" + String.valueOf(nonce)
				+ "&oauth_signature_method=HMAC-SHA1"
				+ "&oauth_timestamp=" + String.valueOf(timestamp)
				+ "&x_auth_username=" + username
				+ "&x_auth_password=" + password
				+ "&x_auth_mode=client_auth";
	

		try {
			params = "GET&" + URLEncoder.encode(url.toString(),"UTF-8")
						+ "&" + URLEncoder.encode(params,"UTF-8");
		} catch (UnsupportedEncodingException e) {
			setLog("编码错误");
		}

		String sig = generateSignature(params);
		
		authorization = "OAuth realm=\"Fantalker\",oauth_consumer_key=\"" + consumer_key
					+ "\",oauth_signature_method=\"HMAC-SHA1\""
					+ ",oauth_timestamp=\"" + String.valueOf(timestamp) + "\""
					+ ",oauth_nonce=\"" + String.valueOf(nonce) + "\""
					+ ",oauth_signature=\"" + sig + "\""
					+ ",x_auth_username=\"" + username + "\""
					+ ",x_auth_password=\"" + password + "\""
					+ ",x_auth_mode=\"client_auth\"";
		
		try {
			HttpURLConnection connection;
			connection = (HttpURLConnection) url.openConnection();
			connection.setRequestMethod("GET");
			connection.addRequestProperty("Authorization",authorization);
			connection.connect();
			
	
			String line;
			if(connection.getResponseCode() == 200)
			{
				
			}
			else if(connection.getResponseCode() == 401)
			{
				BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
				String log = Main.txtLog.getText();
				line = reader.readLine();
				while(line != null)
				{
					log = log + "\r\n" + line;
					line = reader.readLine();
				}
				Main.txtLog.setText(log);
				JOptionPane.showMessageDialog(null, "用户id或密码错误", "错误", JOptionPane.ERROR_MESSAGE);
				return null;
			}
			else
			{
				BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getErrorStream()));
				String log = Main.txtLog.getText();
				line = reader.readLine();
				while(line != null)
				{
					log = log + "\r\n" + line;
					line = reader.readLine();
				}
				setLog(log);
				JOptionPane.showMessageDialog(null, "未知错误，请重试", "错误", JOptionPane.ERROR_MESSAGE);
				return null;
			}
			BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			line = reader.readLine();
			return line;
		} catch (SocketTimeoutException e) {
			setLog("连接超时，请重试:" + e.getMessage());
			return null;
		} catch (IOException e) {
			setLog("创建输入流时发生 I/O错误:" + e.getMessage());
			return null;
		}
	}