WxPusher 演示程序
+WxPusher消息推送平台 - 演示程序
使用WxPusher免费推送消息到个人微信上,更快更便捷。本程序已经开源,你可以点击这里参考源码。
@@ -159,6 +159,7 @@
var user = response.data.data.scan;
if (!hasUser && user) {
hasUser = true;
+ clearInterval(interval);
var tips = document.getElementById("step-1");
tips.innerText = "1、已经成功获取到扫码用户,信息如下:"
tips.setAttribute("style", "color:#42b983");
diff --git a/demo/src/test/java/com/zjiecode/wxpusher/demo/DemoTest.java b/demo/src/test/java/com/zjiecode/wxpusher/demo/DemoTest.java
deleted file mode 100644
index 164e06f..0000000
--- a/demo/src/test/java/com/zjiecode/wxpusher/demo/DemoTest.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.zjiecode.wxpusher.demo;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
-
-/**
- * 说明:测试代码
- * 作者:zjiecode
- * 时间:2019-10-05
- */
-
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = JavaWebApplication.class)
-public class DemoTest {
- @Test
- public void test() {
- System.out.println("test");
- }
-
-}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5d383c7..5b5aed8 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
diff --git a/publish.sh b/publish.sh
deleted file mode 100644
index 7d948a6..0000000
--- a/publish.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-
-./gradlew sdk:clean sdk:build sdk:bintrayUpload -PbintrayApiKey=$BINTRAY_API_KEY
\ No newline at end of file
diff --git a/sdk/build.gradle b/sdk/build.gradle
deleted file mode 100644
index 0fe4de9..0000000
--- a/sdk/build.gradle
+++ /dev/null
@@ -1,81 +0,0 @@
-apply plugin: 'java'
-apply plugin: 'maven-publish'
-apply plugin: 'com.jfrog.bintray'
-
-
-//包配置信息
-ext {
- version = "2.1.8-local"
- artifactId = "wxpusher-java-sdk"
- projectUrl = "https://github.com/wxpusher/wxpusher-java-sdk.git"
- description = "微信消息实时推送服务[WxPusher],可以通过API实时给个人微信推送消息,详情请看:http://wxpusher.zjiecode.com/docs"
- user = 'zjiecode'
-}
-
-repositories {
- jcenter()
- mavenCentral()
-}
-dependencies {
- compile 'com.alibaba:fastjson:1.2.70'
- testCompile 'junit:junit:4.12'
-}
-
-publishing {
- publications {
- Production(MavenPublication) {
- from components.java
- artifact sourcesJar
- artifact javadocJar
- groupId 'com.zjiecode'
- artifactId this.ext.artifactId
- version this.ext.version
- pom.withXml {
- //添加pom中缺失的信息,以发布到mavencenter
- def projectNode = asNode()
- projectNode.appendNode('name', this.ext.artifactId)
- projectNode.appendNode('description', this.ext.description)
- projectNode.appendNode('url', this.ext.projectUrl)
- projectNode.appendNode('scm').appendNode("url", this.ext.projectUrl)
- def license = projectNode.appendNode('licenses').appendNode("license")
- license.appendNode('name', "MIT")
- license.appendNode('url', "https://mit-license.org/")
- def developer = projectNode.appendNode("developers").appendNode("developer")
- developer.appendNode("id", "zjiecode")
- developer.appendNode("email", "zjiecode@qq.com")
- }
- }
- }
-}
-
-
-bintray {
- user = this.ext.user
- key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
- publications = ['Production']
- pkg {
- repo = 'maven'
- name = this.ext.artifactId
- userOrg = this.ext.user
- licenses = ['MIT']
- vcsUrl = this.ext.projectUrl
- labels = ['wechat', 'push', 'notification', 'pushsdk']
- publicDownloadNumbers = true
- version {
- desc = this.ext.description
- vcsTag = this.ext.version
- released = new Date()
- name = this.ext.version
- }
- }
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
diff --git a/sdk/src/main/java/com/zjiecode/wxpusher/client/HttpUtils.java b/sdk/src/main/java/com/zjiecode/wxpusher/client/HttpUtils.java
deleted file mode 100644
index 170c697..0000000
--- a/sdk/src/main/java/com/zjiecode/wxpusher/client/HttpUtils.java
+++ /dev/null
@@ -1,187 +0,0 @@
-package com.zjiecode.wxpusher.client;
-
-import com.alibaba.fastjson.JSONObject;
-import com.zjiecode.wxpusher.client.bean.Result;
-import com.zjiecode.wxpusher.client.bean.ResultCode;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * 说明:网络请求工具
- * 作者:zjiecode
- * 时间:2019-09-05
- */
-public final class HttpUtils {
- private static final String BASE_URL = "https://wxpusher.zjiecode.com";
- private static final String CHARSET_NAME ="UTF-8";
-
- private HttpUtils() {
- }
-
- /**
- * 发送post请求
- *
- * @param data 发送的数据
- * @param path 请求后台的path
- * @return 发送的result结果
- */
- public static Result post(Object data, String path) {
- try {
- if (data == null) {
- return new Result(ResultCode.UNKNOWN_ERROR, "数据为空");
- }
- String dataStr = JSONObject.toJSONString(data);
-
- URL cUrl = new URL(buildUrl(path));
- HttpURLConnection urlConnection = (HttpURLConnection) cUrl.openConnection();
- urlConnection.setConnectTimeout(60000);
- urlConnection.setReadTimeout(60000);
- urlConnection.setUseCaches(false);
- urlConnection.setRequestMethod("POST");
- //设置请求属性
- urlConnection.setRequestProperty("Content-Type", "application/json");
- urlConnection.setRequestProperty("Charset", CHARSET_NAME);
- urlConnection.setDoOutput(true);
- urlConnection.connect();
- OutputStream outputStream = urlConnection.getOutputStream();
- outputStream.write(dataStr.getBytes(Charset.forName(CHARSET_NAME)));
- outputStream.flush();
- return dealConnect(urlConnection);
- } catch (MalformedURLException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.getMessage());
- } catch (IOException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.toString());
- } catch (Throwable e) {
- return new Result(ResultCode.UNKNOWN_ERROR, e.toString());
- }
- }
-
- public static Result get(String path) {
- return get(null, path);
- }
-
- /**
- * 发送get请求
- */
- public static Result get(Map data, String path) {
- try {
- String url = buildUrl(path);
- String query = parseMap2Query(data);
- if (!query.isEmpty()) {
- url = url + "?" + query;
- }
- URL cUrl = new URL(url);
- HttpURLConnection urlConnection = (HttpURLConnection) cUrl.openConnection();
- urlConnection.setConnectTimeout(60000);
- urlConnection.setReadTimeout(60000);
- urlConnection.setUseCaches(false);
- urlConnection.setRequestMethod("GET");
- //设置请求属性
- urlConnection.setRequestProperty("Charset", CHARSET_NAME);
- urlConnection.setDoOutput(true);
- urlConnection.connect();
- return dealConnect(urlConnection);
- } catch (MalformedURLException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.getMessage());
- } catch (IOException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.toString());
- } catch (Throwable e) {
- return new Result(ResultCode.UNKNOWN_ERROR, e.toString());
- }
- }
-
- /**
- * 把map转成query查询字符串
- */
- private static String parseMap2Query(Map data) {
- if (data == null || data.size() <= 0) {
- return "";
- }
- Set> entries = data.entrySet();
- StringBuilder stringBuilder = new StringBuilder();
- for (Map.Entry entry : entries) {
- if (stringBuilder.length() > 0) {
- stringBuilder.append("&");
- }
- stringBuilder.append(entry.getKey()).append("=").append(entry.getValue());
- }
- return stringBuilder.toString();
- }
-
- /**
- *
- */
- private static String buildUrl(String path) {
- String url = BASE_URL;
- if (path != null && path.length() > 0) {
- if (path.startsWith("/")) {
- url = BASE_URL + path;
- } else {
- url = BASE_URL + "/" + path;
- }
- }
- return url;
- }
-
- /**
- * 处理连接以后的状态信息
- *
- * @param urlConnection 打开的连接
- * @return 返回发送结果
- */
- private static Result dealConnect(HttpURLConnection urlConnection) {
- try {
- int responseCode = urlConnection.getResponseCode();
- if (responseCode != 200) {
- return new Result(urlConnection.getResponseCode(), "http请求错误:" + responseCode);
- }
- InputStream inputStream = urlConnection.getInputStream();
- String res = inputStream2String(inputStream);
- if (res == null || res.isEmpty()) {
- return new Result(ResultCode.INTERNAL_SERVER_ERROR, "服务器返回异常");
- }
- Result result = JSONObject.parseObject(res, Result.class);
- if (result == null) {
- return new Result(ResultCode.DATA_ERROR, "服务器返回数据解析异常");
- }
- return result;
- } catch (MalformedURLException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.getMessage());
- } catch (IOException e) {
- return new Result(ResultCode.NETWORK_ERROR, e.getMessage());
- } catch (Throwable e) {
- return new Result(ResultCode.UNKNOWN_ERROR, e.getMessage());
- }
- }
-
- /**
- * 从输入流中读取内容到字符串
- *
- * @param inputStream 输入路
- * @return 返回字符串
- */
- private static String inputStream2String(InputStream inputStream) {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- int len = 0;
- byte[] bytes = new byte[4096];
- try {
- while ((len = inputStream.read(bytes)) != -1) {
- outputStream.write(bytes, 0, len);
- }
- return new String(outputStream.toByteArray(),CHARSET_NAME);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return null;
- }
-}
diff --git a/sdk/src/main/java/com/zjiecode/wxpusher/client/WxPusher.java b/sdk/src/main/java/com/zjiecode/wxpusher/client/WxPusher.java
deleted file mode 100644
index 2d4cc6a..0000000
--- a/sdk/src/main/java/com/zjiecode/wxpusher/client/WxPusher.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package com.zjiecode.wxpusher.client;
-
-import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
-import com.zjiecode.wxpusher.client.bean.*;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * 说明:WxPusher的客户端
- * 作者:zjiecode
- * 时间:2019-05-03
- */
-public final class WxPusher {
- private WxPusher() {
- }
-
- /**
- * 发送消息
- */
- public static Result
- > send(Message message) {
- Result result = verify(message);
- if (result != null) {
- return result;
- }
- Result sendResult = HttpUtils.post(message, "/api/send/message");
- if (sendResult.isSuccess()) {
- //转换,方便调用
- Object data = sendResult.getData();
- String s = JSONObject.toJSONString(data);
- List
- >() {
- });
- sendResult.setData(messageResults);
- }
- return sendResult;
- }
-
- /**
- * 查询消息发送状态
- */
- public static Result queryMessageStatus(Long messageId) {
- if (messageId == null || messageId <= 0) {
- return new Result(ResultCode.BIZ_FAIL, "messageId为空");
- }
- return HttpUtils.get(String.format("/api/send/query/%s", messageId));
- }
-
- /**
- * 创建带参数的app临时二维码
- */
- public static Result
"); - message.setAppToken("AT_a2zb61nhS33h54NOLvSYxgrMO4KcJ2vG"); - message.setUid("UID_LffjrW6nh4vpNWGC85QMzX82OURf"); - Result
- > result = WxPusher.send(message);
- count.incrementAndGet();
- if (!result.isSuccess()) {
- System.out.println(JSONObject.toJSONString(result));
- }
- if (count.get() % 100 == 0) {
- long during = System.currentTimeMillis() - time.get();
- time.set(System.currentTimeMillis());
- System.out.println(count.get() + "-" + (100F / during * 1000F));
- }
- }
- }).start();
- }
-
- }
-
- @Test
- public void testQuery() {
- Result