急!人人网API的初级连接问题 第一个是获取签名的函数: public String getSignature(List<String> paramList,String secret)不知道第一个参数是什么东西?请高手赐教。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 第二个是发送请求:代码如下:就是官网上的代码: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)。 这个要加入一个commons-httpclient.jar包,注意要3.x版本的,4.0以上已没有postmethod了 引入Android项目,运行时有FileIO异常 怎么把android OpenGL ES 绘制的图像背景变为透明? Android模拟机运行时,会突然奔溃,显示问题是内存不可读 请教一个关于EditText的问题 急:android动画 如何绕Y轴旋转,求代码 ExpandableListView与ScrollView android的camera问题 android servlet服务器 json 交互问题 求帮助~~~~~~~ 获取平板手机休眠状态 qq登陆 100044问题 webview载入页面和手机的网有关吗?在线等 Android是不是还隐藏着一个拨号键盘?
代码如下:就是官网上的代码:
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)。