Skip to content

Commit 8c360a1

Browse files
author
vunited
committed
2020-1-7 last
1 parent b4a77bc commit 8c360a1

File tree

294 files changed

+847
-11073
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

294 files changed

+847
-11073
lines changed

.classpath

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
3-
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/Java SE 8 [1.8.0_191]">
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
44
<attributes>
55
<attribute name="module" value="true"/>
66
<attribute name="maven.pomderived" value="true"/>
77
</attributes>
88
</classpathentry>
9-
<classpathentry excluding="resources/|resources/com/aliyuncs/sdk/|aliyun-java-sdk-core/src/main/resources/|baseFile/|spider-flow-api/|spider-flow-core/|spider-flow-web/|aliyun-java-sdk-core/src/main/java/com/aliyuncs/|aliyun-java-sdk-core/src/main/java/com/aliyuncs/" kind="src" path="APITest"/>
10-
<classpathentry kind="src" path="APITest/aliyun-java-sdk-core/src/main/resources"/>
11-
<classpathentry kind="src" path="APITest/aliyun-java-sdk-core/src/main/java/com/aliyuncs"/>
12-
<classpathentry kind="src" path="Base"/>
9+
<classpathentry excluding="resources/|resources/com/aliyuncs/sdk/|aliyun-java-sdk-core/src/main/resources/|baseFile/|spider-flow-api/|spider-flow-core/|spider-flow-web/|aliyun-java-sdk-core/src/main/java/com/aliyuncs/" kind="src" output="target/classes" path="APITest"/>
10+
<classpathentry kind="src" output="target/classes" path="APITest/aliyun-java-sdk-core/src/main/resources"/>
11+
<classpathentry kind="src" output="target/classes" path="APITest/aliyun-java-sdk-core/src/main/java/com/aliyuncs"/>
12+
<classpathentry kind="src" path="Utils"/>
13+
<classpathentry kind="src" path="GUI"/>
1314
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
14-
<classpathentry exported="true" kind="lib" path="src/hamcrest-2.1.jar"/>
15-
<classpathentry exported="true" kind="lib" path="jsoup-1.12.1.jar"/>
16-
<classpathentry exported="true" kind="lib" path="fastjson-1.2.9.jar"/>
17-
<classpathentry exported="true" kind="lib" path="sdk-core-java-1.1.0-sources.jar"/>
18-
<classpathentry exported="true" kind="lib" path="sdk-core-java-1.1.0.jar"/>
15+
<classpathentry exported="true" kind="lib" path="hamcrest-2.1.jar"/>
16+
<classpathentry kind="lib" path="sdk-core-java-1.1.0-sources.jar"/>
17+
<classpathentry kind="lib" path="sdk-core-java-1.1.0.jar"/>
18+
<classpathentry kind="lib" path="lib/ecs.jar"/>
1919
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
2020
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
21-
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21+
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
2222
<attributes>
2323
<attribute name="maven.pomderived" value="true"/>
2424
</attributes>
2525
</classpathentry>
26+
<classpathentry kind="src" output="target/classes" path="src/main/java">
27+
<attributes>
28+
<attribute name="optional" value="true"/>
29+
<attribute name="maven.pomderived" value="true"/>
30+
</attributes>
31+
</classpathentry>
32+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
33+
<attributes>
34+
<attribute name="test" value="true"/>
35+
<attribute name="optional" value="true"/>
36+
<attribute name="maven.pomderived" value="true"/>
37+
</attributes>
38+
</classpathentry>
2639
<classpathentry kind="output" path="target/classes"/>
2740
</classpath>

.settings/org.eclipse.core.resources.prefs

-3
This file was deleted.

.settings/org.eclipse.jdt.core.prefs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
eclipse.preferences.version=1
22
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
33
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
4-
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
55
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
6-
org.eclipse.jdt.core.compiler.compliance=1.6
6+
org.eclipse.jdt.core.compiler.compliance=1.5
77
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
88
org.eclipse.jdt.core.compiler.debug.localVariable=generate
99
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
1010
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
1111
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
1212
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
1313
org.eclipse.jdt.core.compiler.release=disabled
14-
org.eclipse.jdt.core.compiler.source=1.6
14+
org.eclipse.jdt.core.compiler.source=1.5

APITest/Constants.java

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.show.api;
2+
3+
/**
4+
* 公用常量类。
5+
*/
6+
public class Constants {
7+
8+
/** 默认时间格式 **/
9+
public static final String DATE_TIME_FORMAT = "yyyyMMddHHmmss";
10+
11+
/** Date默认时区 **/
12+
public static final String DATE_TIMEZONE = "GMT+8";
13+
14+
/** UTF-8字符集 **/
15+
public static final String CHARSET_UTF8 = "UTF-8";
16+
17+
/** GBK字符集 **/
18+
public static final String CHARSET_GBK = "GBK";
19+
20+
/** JSON 应格式 */
21+
public static final String FORMAT_JSON = "json";
22+
/** XML 应格式 */
23+
public static final String FORMAT_XML = "xml";
24+
25+
/** MD5签名方式 */
26+
public static final String SIGN_METHOD_MD5 = "md5";
27+
/** HMAC签名方式 */
28+
public static final String SIGN_METHOD_HMAC = "hmac";
29+
30+
31+
32+
33+
}

APITest/Demo.java

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
2+
import java.io.File;
3+
import java.io.FileInputStream;
4+
import java.util.Iterator;
5+
import java.util.Map;
6+
7+
import com.show.api.util.Base64;
8+
import com.show.api.util.WebUtils;
9+
10+
public class Demo {
11+
public static void 今日油价(String adfas[]) throws Exception {
12+
byte b[] = new ShowapiRequest("http://ali-todayoil.showapi.com/todayoil", "appcode").addTextPara("prov", "北京")
13+
.getAsByte();
14+
String str = new String(b, "utf-8");
15+
System.out.println(str);
16+
}
17+
18+
public static void ip(String adfas[]) throws Exception {
19+
byte b[] = new ShowapiRequest("https://ali-ip.showapi.com/ip", "appcode").addTextPara("ip", "223.5.5.5")
20+
.getAsByte();
21+
String str = new String(b, "utf-8");
22+
System.out.println(str);
23+
}
24+
25+
public static void 三网手机认证() throws Exception {
26+
ShowapiRequest req = new ShowapiRequest("https://auditphone.showapi.com/phoneAudit", "appcode");
27+
byte b[] = req.addTextPara("typeId", "1").addTextPara("page", "1").getAsByte();
28+
String str = new String(b, "utf-8");
29+
Map map = req.getRes_headMap();
30+
Iterator it = map.keySet().iterator();
31+
while (it.hasNext()) {
32+
Object k = it.next();
33+
System.out.println(k + " " + map.get(k));
34+
}
35+
System.out.println(str);
36+
37+
}
38+
39+
public static void 银行卡归属地() throws Exception {
40+
ShowapiRequest req = new ShowapiRequest("https://ali-bankcard4.showapi.com/bank4", "appcode");
41+
byte b[] = req.addTextPara("typeId", "1").addTextPara("page", "1").getAsByte();
42+
String str = new String(b, "utf-8");
43+
Map map = req.getRes_headMap();
44+
Iterator it = map.keySet().iterator();
45+
while (it.hasNext()) {
46+
Object k = it.next();
47+
System.out.println(k + " " + map.get(k));
48+
}
49+
System.out.println(str);
50+
51+
}
52+
53+
public static void 发送短信() throws Exception {
54+
ShowapiRequest req = new ShowapiRequest("http://ali-sms.showapi.com/sendSms", "appcode");
55+
byte b[] = req.addTextPara("content", "1").addTextPara("mobile", "1").addTextPara("tNum", "1").getAsByte();
56+
String str = new String(b, "utf-8");
57+
Map map = req.getRes_headMap();
58+
Iterator it = map.keySet().iterator();
59+
while (it.hasNext()) {
60+
Object k = it.next();
61+
System.out.println(k + " " + map.get(k));
62+
}
63+
System.out.println(str);
64+
65+
}
66+
67+
public static void main(String adfas[]) throws Exception {
68+
图片验证();
69+
}
70+
71+
public static void 虾米音乐(String adfas[]) throws Exception {
72+
ShowapiRequest req = new ShowapiRequest("http://ali-music.showapi.com/xiamimusic-top", "appcode");
73+
byte b[] = req.addTextPara("typeId", "1").addTextPara("page", "1").getAsByte();
74+
String str = new String(b, "utf-8");
75+
Map map = req.getRes_headMap();
76+
Iterator it = map.keySet().iterator();
77+
while (it.hasNext()) {
78+
Object k = it.next();
79+
System.out.println(k + " " + map.get(k));
80+
}
81+
System.out.println(str);
82+
}
83+
84+
public static void 违章(String adfas[]) throws Exception {
85+
ShowapiRequest req = new ShowapiRequest("https://ali-shanxi-car.showapi.com/sxwz_info", "appcode")
86+
.addTextPara("carEngineCode", "BA40335").addTextPara("carNumber", "陕AF426G")
87+
.addTextPara("carType", "02");
88+
byte b[] = req.getAsByte();
89+
String str = new String(b, "utf-8");
90+
System.out.println(str);
91+
Map map = req.getRes_headMap();
92+
Iterator it = map.keySet().iterator();
93+
while (it.hasNext()) {
94+
Object k = it.next();
95+
System.out.println(k + " " + map.get(k));
96+
}
97+
}
98+
99+
public static void 微信查询(String adfas[]) throws Exception {
100+
ShowapiRequest req = new ShowapiRequest("http://ali-weixin.showapi.com/582-9", "appcode").addTextPara("url",
101+
" ");
102+
103+
byte b[] = req.getAsByte();
104+
String str = new String(b, "utf-8");
105+
System.out.println(str);
106+
Map map = req.getRes_headMap();
107+
Iterator it = map.keySet().iterator();
108+
while (it.hasNext()) {
109+
Object k = it.next();
110+
System.out.println(k + " " + map.get(k));
111+
}
112+
}
113+
114+
public static void ip查询天气(String adfas[]) throws Exception {
115+
ShowapiRequest req = new ShowapiRequest("https://ali-weather.showapi.com/ip-to-weather", "appcode")
116+
.addTextPara("ip", "223.5.5.5");
117+
byte b[] = req.getAsByte();
118+
String str = new String(b, "utf-8");
119+
System.out.println(str);
120+
Map map = req.getRes_headMap();
121+
Iterator it = map.keySet().iterator();
122+
while (it.hasNext()) {
123+
Object k = it.next();
124+
System.out.println(k + " " + map.get(k));
125+
}
126+
}
127+
128+
public static void 快递(String adfas[]) throws Exception {
129+
ShowapiRequest req = new ShowapiRequest("http://ali-deliver.showapi.com/showapi_expInfo", "appcode")
130+
.addTextPara("paraname", "xxxxx").addTextPara("paraname", "xxxxx").addTextPara("paraname", "xxxxx");
131+
byte b[] = req.postAsByte();
132+
String str = new String(b, "utf-8");
133+
System.out.println("aaaaaaaaaaaa");
134+
System.out.println(str);
135+
Map map = req.getRes_headMap();
136+
Iterator it = map.keySet().iterator();
137+
System.out.println("bbbbbbbbbbb");
138+
while (it.hasNext()) {
139+
Object k = it.next();
140+
System.out.println(k + " " + map.get(k));
141+
}
142+
}
143+
144+
public static void 图片验证() throws Exception {
145+
ShowapiRequest req = new ShowapiRequest("http://ali-checkcode2.showapi.com/checkcode", "appcode");
146+
byte img[] = WebUtils.readByteFromStream(new FileInputStream(new File("c:/g86pm.jpg")));
147+
String base64string = new String(Base64.encode(img));
148+
System.out.println(base64string);
149+
byte b[] = req.addTextPara("typeId", "3000").addTextPara("convert_to_jpg", "0")
150+
.addTextPara("img_base64", base64string).postAsByte();
151+
// 打印返回头
152+
Map map = req.getRes_headMap();
153+
Iterator it = map.keySet().iterator();
154+
while (it.hasNext()) {
155+
Object k = it.next();
156+
System.out.println(k + " " + map.get(k));
157+
}
158+
// 打印返回体
159+
String res = new String(b, "utf-8");
160+
System.out.println(res);
161+
162+
// 下面是使用阿里的fastjson包解析。如果不需要,请使用自己的解析包
163+
// JSONObject json=JSONObject.parseObject(res);
164+
// System.out.println(json.getJSONObject("showapi_res_body"));
165+
}
166+
}

APITest/FileItem.java

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.show.api;
2+
3+
import java.io.ByteArrayOutputStream;
4+
import java.io.File;
5+
import java.io.FileInputStream;
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
9+
import com.show.api.util.ShowApiUtils;
10+
11+
12+
/**
13+
* 文件元数据。
14+
*/
15+
public class FileItem {
16+
17+
private String fileName;
18+
private String mimeType;
19+
private byte[] content;
20+
private File file;
21+
22+
/**
23+
* 基于本地文件的构造器。
24+
*
25+
* @param file 本地文件
26+
*/
27+
public FileItem(File file) {
28+
this.file = file;
29+
}
30+
31+
/**
32+
* 基于文件绝对路径的构造器。
33+
*
34+
* @param filePath 文件绝对路径
35+
*/
36+
public FileItem(String filePath) {
37+
this(new File(filePath));
38+
}
39+
40+
/**
41+
* 基于文件名和字节流的构造器。
42+
*
43+
* @param fileName 文件名
44+
* @param content 文件字节流
45+
*/
46+
public FileItem(String fileName, byte[] content) {
47+
this.fileName = fileName;
48+
this.content = content;
49+
}
50+
51+
/**
52+
* 基于文件名、字节流和媒体类型的构造器。
53+
*
54+
* @param fileName 文件名
55+
* @param content 文件字节流
56+
* @param mimeType 媒体类型
57+
*/
58+
public FileItem(String fileName, byte[] content, String mimeType) {
59+
this(fileName, content);
60+
this.mimeType = mimeType;
61+
}
62+
63+
public String getFileName() {
64+
if (this.fileName == null && this.file != null && this.file.exists()) {
65+
this.fileName = file.getName();
66+
}
67+
return this.fileName;
68+
}
69+
70+
public String getMimeType() throws IOException {
71+
if (this.mimeType == null) {
72+
this.mimeType = ShowApiUtils.getMimeType(getContent());
73+
}
74+
return this.mimeType;
75+
}
76+
77+
public byte[] getContent() throws IOException {
78+
if (this.content == null && this.file != null && this.file.exists()) {
79+
InputStream in = null;
80+
ByteArrayOutputStream out = null;
81+
82+
try {
83+
in = new FileInputStream(this.file);
84+
out = new ByteArrayOutputStream();
85+
int ch;
86+
while ((ch = in.read()) != -1) {
87+
out.write(ch);
88+
}
89+
this.content = out.toByteArray();
90+
} finally {
91+
if (out != null) {
92+
out.close();
93+
}
94+
if (in != null) {
95+
in.close();
96+
}
97+
}
98+
}
99+
return this.content;
100+
}
101+
102+
}

0 commit comments

Comments
 (0)