请教高人,我刚学java网络编程不久,想做一个“人人网”共享程序,但是一直不能成功,想请帮我看看我的程序错在哪里,代码如下:
用的是httpClient 3.1工具包
public class httpLogin {    final String LOGON_SITE = "www.renren.com";
    final int    LOGON_PORT = 80;
    private Calendar calendar;    private HttpClient client;    private String tsc;    public httpLogin() {        client = new HttpClient();
        client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT, "http");
        client.getParams().setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
        GetMethod authget = new GetMethod("/");        try {
            client.executeMethod(authget);
        } catch (IOException ex) {
        }
        System.out.println("Login form get: " + authget.getStatusLine().toString());
        authget.releaseConnection();
        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
        Cookie[] initcookies = cookiespec.match(
            LOGON_SITE, LOGON_PORT, "/", false, client.getState().getCookies());
        System.out.println("Initial set of cookies:");//打印Cookies
        if (initcookies.length == 0) {
            System.out.println("None");
        } else {
            for (int i = 0; i < initcookies.length; i++) {
                System.out.println("- " + initcookies[i].toString());
            }
        }    }    public boolean login(){//登录
        NameValuePair nvp[] = {
                              new NameValuePair("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1"),
                              new NameValuePair("Accept",
                                                "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"),
                              new NameValuePair("Accept-Language",
                                                "zh-cn,en-us;q=0.7,zh;q=0.3"),
                              new NameValuePair("Accept-Charset",
                                                "gb2312,utf-8;q=0.7,*;q=0.7"),
                              new NameValuePair("email", "tyhjaocn200901"),
                              new NameValuePair("password", "87189118")
        };        PostMethod post = new PostMethod("http://passport.renren.com/PLogin.do");
        post.setRequestBody(nvp);
        try {
            client.executeMethod(post);
            int status = post.getStatusCode();
            if (status == 302) {
                calendar = Calendar.getInstance();
                System.out.println("\n登录成功! "+calendar.get(calendar.YEAR)+"年"+(calendar.get(calendar.MONTH)+1)+"月"+calendar.get(calendar.DAY_OF_MONTH)+"日 "+calendar.get(calendar.HOUR_OF_DAY)+":"+calendar.get(calendar.MINUTE)+":"+calendar.get(calendar.SECOND)+"\n");
                return true;
            }
        } catch (Exception e) {
            if (e.getMessage().contains("Read")) {
                System.out.println("登录超时!");
                System.exit(1);
            }
        } finally {
            post.releaseConnection();
        }
        System.out.println("登录失败\n");
        return false;
    }    public void toShare(){//跳转到共享页面
        GetMethod getMethod = new GetMethod("http://share.renren.com/");
        try {
            client.executeMethod(getMethod);
            int status = getMethod.getStatusCode();
            if (status == 200) {
                System.out.println("OK!");
            }
        } catch (IOException ex) {
        } finally {
            getMethod.releaseConnection();
        }this.cookies();
this.sendLink();
    }    public void cookies(){//设置cookies
        CookieSpec cookiespec = CookiePolicy.getDefaultSpec();
       Cookie[] initcookies = cookiespec.match(
           LOGON_SITE, LOGON_PORT, "/", false, client.getState().getCookies());
       System.out.println("Initial set of cookies:");
       if (initcookies.length == 0) {
           System.out.println("None");
       } else {
           for (int i = 0; i < initcookies.length; i++) {
               System.out.println("- " + initcookies[i].toString());
           }
       }    }    public void sendLink() {//人人网分享的第一个共享页面提交
        NameValuePair nvp[] = {
                              new NameValuePair("action", "sharelink"),
                              new NameValuePair("weblink","http://www.tyhjao.cn"),
        };
        PostMethod post = new PostMethod("http://share.renren.com/share/ShareLink.do");
        post.setRequestBody(nvp);
        try {
            client.executeMethod(post);
            int status = post.getStatusCode();
            if (status == 200) {
                System.out.println("\n跳转成功\n");
            }
            InputStream input = post.getResponseBodyAsStream();
            String cont = readContent(input);
            int start = 0;
            tsc = cont.substring(start = (cont.lastIndexOf("tsc") + 12),cont.indexOf("\"", start));
            System.out.println(tsc);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            post.releaseConnection();
            this.cookies();
        }
        lastLink();
    }    public void lastLink() {//分享提交
       NameValuePair nvp[] = {
                             new NameValuePair("link", "http://www.tyhjao.cn"),
                             new NameValuePair("pic", ""),
                             new NameValuePair("type", "6"),
                             new NameValuePair("fromno", "0"),
                             new NameValuePair("fromname", ""),
                             new NameValuePair("fromuniv", ""),
                             new NameValuePair("summary", ""),
                             new NameValuePair("referer", ""),
                             new NameValuePair("tsc", tsc),
                             new NameValuePair("action", "add"),
                             new NameValuePair("body", "001"),
                             new NameValuePair("auth", "99"),
                             new NameValuePair("title", "0001"),
       };
       PostMethod post = new PostMethod(
               "http://share.renren.com/share/ajaxSaveShare.do");
       post.setRequestBody(nvp);
       try {
           client.executeMethod(post);
           int status = post.getStatusCode();
           if (status == 302||status==301) {
               Header locationHeader = post.getResponseHeader("location");
               String location = null;
               if(locationHeader!=null){
                   location = locationHeader.getValue();
                   System.out.println("The page was redirectes to:"+location);
               }
               System.out.println("\n share is successful1 \n");
           } else if(status == 200){
               System.out.println("共享成功!");
           }
           else {
               System.out.println("field1");//13305166710
           }
       } catch (Exception e) {
           e.printStackTrace();
       } finally {
           post.releaseConnection();
           this.cookies();
       }
   }    public static void main(String[] args) throws Exception{        httpLogin login = new httpLogin();
        login.login();
        login.toShare();    }    private static String readContent(InputStream is) throws Exception {//将输入流转换成html
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = "";
        StringBuilder sb = new StringBuilder();
        while ((line = br.readLine()) != null) {
            sb.append(line + "\n");
        }
        br.close();
        return new String(sb.toString().getBytes(), "utf-8");
    }
}