开发学院软件开发Java 邀请QQ好友-QQ联系人导入(上) 阅读

邀请QQ好友-QQ联系人导入(上)

 2009-09-06 00:00:00 来源:WEB开发网   
核心提示: ---action.jsp--Jsp代码 <%@pagelanguage="java"pageEncoding="UTF-8"%><%@pageimport="qq.QQContactsService"%><

-----------action.jsp----------

Jsp代码

<%@ page language="java" pageEncoding="UTF-8"%> 
<%@page import="qq.QQContactsService"%> 
<%@page import="qq.AuthInfo"%> 
<%@page import="java.util.List"%> 
<%@page import="qq.QQContact"%> 
<% 
  String uin = request.getParameter("uin").trim(); 
  String pp = request.getParameter("pp").trim(); 
  String p = request.getParameter("p").trim(); 
  String ts = request.getParameter("ts").trim(); 
  String starttime = request.getParameter("starttime").trim(); 
  String verifycode = request.getParameter("verifycode").trim(); 
  String domain = request.getParameter("domain").trim(); 
  String cookie = request.getHeader("cookie"); 
   
  System.out.println(cookie); 
  QQContactsService service =QQContactsService.getInstance(); 
   
  AuthInfo auth = new AuthInfo(); 
  auth.putParam("uin",uin); 
  auth.putParam("pp",pp); 
  auth.putParam("p",p); 
  auth.putParam("ts",ts); 
  auth.putParam("starttime",starttime); 
  auth.putParam("verifycode",verifycode); 
  auth.putParam("domain",domain); 
  auth.putParam("cookie",cookie); 
  System.out.println(auth.getParam()); 
  List<QQContact> list = null; 
   
  try{ 
   list = service.getQQContacts(auth); 
  }catch(Exception e){ 
   if(e == QQContactsService.QQ_WRONG_PWD){ 
   out.println("密码错误");  
   }else if(e == QQContactsService.QQ_WRONG_VERIFY){ 
   out.println("验证码错误"); 
   }else if(e == QQContactsService.QQ_MANY_LOGIN_TIMES){ 
   out.println("登录次数太多,稍后再试"); 
   }else if(e == QQContactsService.QQ_EEROR){ 
   out.println("服务器错误,可能代码已经失效"); 
   }else{ 
   out.println("服务器错误"); 
   } 
   return ; 
  } 
   
  if(list == null){ 
   out.println("没有取到联系人,可能代码已经失效"); 
   return ; 
  } 
   
  for(QQContact c:list){ 
   out.println(c.getEmail()+" "+c.getName()+"("+c.getQq()+")<br>"); 
  } 
 %>  
 

-------code.jsp----------------

Jsp代码

  

%>  

<%@ page language="java" pageEncoding="UTF-8" contentType="image/jpeg"%> 
<%@page import="org.apache.commons.httpclient.Cookie"%> 
<%@page import="qq.QQContactsService"%> 
<%@page import="qq.VerifyCode"%> 
<%   
  QQContactsService service = QQContactsService.getInstance(); 
   
  VerifyCode code = service.getVerifyCode(); 
  byte[] data = code.getData(); 
   
  Cookie c = code.getVerifySession(); 
  response.addCookie(new javax.servlet.http.Cookie(c.getName(),c.getValue())); 
   
  ServletOutputStream outStream = response.getOutputStream(); 
  outStream.write(data); 
   
  out.clear(); 
  out = pageContext.pushBody(); 
   
%>
 

-----------index.jsp-------------

上一页  2 3 4 5 6 7 

Tags:邀请 QQ 好友

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接