第一个是获取签名的函数:
    public String getSignature(List<String> paramList,String secret)
不知道第一个参数是什么东西?请高手赐教。

解决方案 »

  1.   

    第二个是发送请求:
    代码如下:就是官网上的代码:
    public static void main(String[] args) throws Exception {
    long  time = System.currentTimeMillis();
    String strTime = URLEncoder.encode(String.valueOf(time));  //系统的当前时间,作为call_id的值
    String secret = "49617buiyd00404239240f88c8cb3e02";    //应用的Secret Key
    String apiKey = "eabd87cf9087486e8f7861b57d91a4ee";     //应用的API Key
    String requestMethod = "users.getEvent";                          //接口名称
    String v = "1.0";                                                              //API的版本号,请设置成1.0
    String sessionKey = "7c8dc0bf83a148bc97bfa804b07a1a10-227967782";    //通过上述验证授权过程得到的Session Key,注意需要URL编码
    String fields = "notification_count,tag_request_count";                             //请求接口所要求的参数,因接口不同而不同,下面接口列表中点击接口名进入的页面会详细介绍
    String url = "http://api.renren.com/restserver.do";                                    //请求人人网开放平台API服务器的地址
                    String signature = “wierydkf22334324234”;                                             //上述的签名 PostMethod method = new PostMethod(url);                //将以上准备好的参数添加到method对象中
    method.addParameter("api_key", apiKey);
    method.addParameter("method", requestMethod);
    method.addParameter("call_id", strTime);
    method.addParameter("v", v);
    method.addParameter("session_key", sessionKey);
    method.addParameter("fields", fields);
    method.addParameter("fangle_types", "all");
    method.addParameter("sig", signature);
                    method.addParameter("format", "JSON");                           //返回结果的形式,支持XML或者JSON两种形式,默认为XML HttpClient client = new HttpClient();
    client.executeMethod(method); String result = method.getResponseBodyAsString();        //返回请求的结果
    }
    代码中的PostMethod  是什么数据类型,怎么eclipse会报错呢?还有HttpClient client = new HttpClient();也有错误(Cannot instantiate the type HttpClient)。
      

  2.   

    这个要加入一个commons-httpclient.jar包,注意要3.x版本的,4.0以上已没有postmethod了