资源简介
完整的java发送http包工程,可发送get及post请求。

代码片段和文件信息
package com.yao.http;
import java.util.linkedHashMap;
import java.util.Map;
import java.io.*;
import java.net.*;
public class Code {
String urlString = “http://login.sina.com.cn/sso/prelogin.php?entry=miniblog&callback=sinaSSOController.preloginCallBack&su=d3VxaW5nY2hlbnhpbmRhJTQwMTYzLmNvbQ%3D%3D&client=ssologin.js(v1.3.12)“;
StringBuffer input = new StringBuffer();
String email=“email“;
String password=“password“;
String entry=“weibo“;
String gateway=“1“;
String from=““;
String savestate=“7“;
String useticket=“1“;
String ssosimplelogin=“1“;
String vsnf=“1“;
String vsnval=““;
String su=“d3VxaW5nY2hlbnhpbmRhJTQwMTYzLmNvbQ%3D%3D“;
String service=“miniblog“;
String servertime;
String nonce;
String pwencode=“wsse“;
String sp;
String encoding=“UTF-8“;
String url=“http%3A%2F%2Fweibo.com%2Fajaxlogin.php%3Fframelogin%3D1%26callback%3Dparent.sinaSSOController.feedBackUrlCallBack“;
String returntype=“meta“;
public Map post() throws UnsupportedEncodingException MalformedURLException IOException{
Getinformation();
Map map = new linkedHashMap();
map.put(“entry“this.entry);
map.put(“gateway“this.gateway);
map.put(“from“this.from);
map.put(“savestate“this.savestate);
map.put(“useticket“this.useticket);
map.put(“ssosimplelogin“this.ssosimplelogin);
map.put(“vsnf“this.vsnf);
map.put(“vsnval“this.vsnval);
map.put(“su“this.su);
map.put(“service“this.service);
map.put(“servertime“servertime);
map.put(“nonce“nonce);//需要调整
map.put(“pwencode“this.pwencode);
map.put(“sp“getSp(this.password this.servertime this.nonce));
map.put(“encoding“this.encoding);
map.put(“url“this.url);
map.put(“returntype“this.returntype);
return map;
}
public void Getinformation() throws UnsupportedEncodingException MalformedURLException IOException
{
InputStreamReader in = new InputStreamReader(new URL(this.urlString).openStream()“UTF-8“);
int ch;
while((ch = in.read())!=-1)
this.input.append((char)ch);
this.servertime=getServerTime(“servertime“);
this.nonce=getServerTime(“nonce“);
}
public String getServerTime(String method) {
int i=this.input.indexOf(“:“this.input.indexOf(method));
int n = 0;
if(method.equalsIgnoreCase(“servertime“))
{
n=this.input.indexOf(““i);
this.servertime=this.input.substring(i+1n);
i++;
}
else if(method.equalsIgnoreCase(“nonce“))
{
n=this.input.indexOf(“\““ i+6);
this.nonce=this.input.substring(i+2n);
i=i+2;
}
System.out.println(this.input);
return this.input.substring(in);
}
public String getSp(String pwd String servertime String nonce){
String sp = new SinaSSOEncoder().encode(pwd servertime nonce);
return sp;
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 368 2018-11-14 16:50 TestURLReceive\.classpath
文件 390 2018-11-14 16:50 TestURLReceive\.project
文件 598 2018-11-14 16:50 TestURLReceive\.settings\org.eclipse.jdt.core.prefs
文件 3990 2018-11-14 16:50 TestURLReceive\bin\com\yao\http\Code.class
文件 7380 2018-11-14 16:50 TestURLReceive\bin\com\yao\http\HttpRequester.class
文件 2470 2018-11-14 16:50 TestURLReceive\bin\com\yao\http\HttpRespons.class
文件 3450 2018-11-14 16:50 TestURLReceive\bin\com\yao\http\SinaSSOEncoder.class
文件 1254 2018-11-14 16:50 TestURLReceive\bin\com\yao\http\Test.class
文件 1248259 2018-11-14 16:50 TestURLReceive\plexus-encryptor-1.0-cli.jar
文件 2984 2018-11-14 16:50 TestURLReceive\src\com\yao\http\Code.java
文件 6781 2018-11-14 16:50 TestURLReceive\src\com\yao\http\HttpRequester.java
文件 1828 2018-11-14 16:50 TestURLReceive\src\com\yao\http\HttpRespons.java
文件 3042 2018-11-14 16:50 TestURLReceive\src\com\yao\http\SinaSSOEncoder.java
文件 1388 2018-11-14 16:50 TestURLReceive\src\com\yao\http\Test.java
目录 0 2018-11-14 16:50 TestURLReceive\bin\com\yao\http
目录 0 2018-11-14 16:50 TestURLReceive\src\com\yao\http
目录 0 2018-11-14 16:50 TestURLReceive\bin\com\yao
目录 0 2018-11-14 16:50 TestURLReceive\src\com\yao
目录 0 2018-11-14 16:50 TestURLReceive\bin\com
目录 0 2018-11-14 16:50 TestURLReceive\src\com
目录 0 2018-11-14 16:50 TestURLReceive\.settings
目录 0 2018-11-14 16:50 TestURLReceive\bin
目录 0 2018-11-14 16:50 TestURLReceive\src
目录 0 2018-11-14 16:50 TestURLReceive
----------- --------- ---------- ----- ----
1284182 24
- 上一篇:Java Mysql图书管理系统
- 下一篇:在线考试系统,oracle,jsp
相关资源
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
- JAVA3D编程示例(建模、交互)
- Java 文件加密传输
- java做的房产管理系统
- 基于jsp的bbs论坛 非常详细
评论
共有 条评论