import java.net.URLEncoder;
public class MyMSN {
public static void main(String[] args) throws Exception {
String username = "fly.net.cn@126.com";
String password = "";
String remoteusername = "lzhfengyun@hotmail.com";
String remoteusername2= "dongbin_23@hotmail.com";
String instantmessage ="test";
MSNServer server = new MSNServer(username, password);
server.login();
server.setStatus();
server.send(remoteusername2, instantmessage);
server.close();
}
}
import java.io.*;
import java.net.*;
import java.util.*;
import java.security.*;
import javax.net.ssl.*;
public class MSNServer {
public String username, password;
private int command = 0;// ·ˮºÍ
private String message;
private Socket server;
private PrintWriter out;
private MSNFilterStream in;
public String temp;
private boolean flag ;
public MSNServer(String username, String password) {
this.username = username;
this.password = password;
}
// µȂ¼
public void login() throws Exception {
server = new Socket("messenger.hotmail.com", 1863);
server.setTrafficClass(0x10);
out = new PrintWriter(server.getOutputStream(), true);
in = new MSNFilterStream(new BufferedInputStream(server
.getInputStream()));
// ±¨¸琭өºÍ
message = "VER " + command + " MSN10 MSNP9 CVRO ";
out.println(message);
command++;
temp = in.readLine();
System.out.println(temp);
// ±¨¸汾»�
message = "CVR " + command
+ " 0x0804 winnt 5.2 i386 MSNMSGR 7.5.0299 MSMSGS " + username
+ " ";
out.println(message);
command++;
temp = in.readLine();
System.out.println(temp);
// ͡½»µȂ¼ԃ»§Ļ
message = "USR " + command + " TWN I " + username + " ";
out.println(message);
command++;
temp = in.readLine();
System.out.println(temp);
// l½ӵ½ns·�
StringTokenizer st = new StringTokenizer(temp);
st.nextToken();
st.nextToken();
st.nextToken();
String ns = st.nextToken();// NSµٖ·
out.close();// ¹ر֓ꃓ·�٬½э
in.close();
server.close();
String[] split = ns.split(":");
server = new Socket(split[0], Integer.parseInt(split[1]));
server.setTrafficClass(0x10);
out = new PrintWriter(server.getOutputStream(), true);
in = new MSNFilterStream(new BufferedInputStream(server
.getInputStream()));
message = "VER " + command + " MSN10 MSNP9 CVR0";
command++;
out.println(message);
temp = in.readLine();
System.out.println(temp);
// ±¨¸汾»�
message = "CVR " + command
+ " 0x0804 winnt 5.2 i386 MSNMSGR 7.5.0299 MSMSGS " + username
+ " ";
out.println(message);
command++;
temp = in.readLine();
// ·¢̍ԃ»§хϢ
message = "USR " + command + " TWN I " + username + " ";
out.println(message);
command++;
// £¡ҩ֤µȂ¼хϢ,˗Ј՚HTTPS¶˿ش43вnexus.passport.com·¢̍һ¸�ȫȳ£¬½«ºš¢Ĝëº̎S¸�һ³¤´®хϢ̍³