Skip to content

Commit

Permalink
Merge pull request #220 from 727288151/dev
Browse files Browse the repository at this point in the history
WxaAPI Add undocodeaudit & revertcoderelease & getwxacodeunlimitresult
  • Loading branch information
liyiorg authored Dec 3, 2019
2 parents 41f8b49 + 6e5c250 commit a576d1e
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 1 deletion.
83 changes: 82 additions & 1 deletion src/main/java/weixin/popular/api/WxaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import javax.imageio.ImageIO;

Expand Down Expand Up @@ -273,6 +274,38 @@ public static BaseResult release(String access_token){
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
}

/**
* 代码管理<br>
* 小程序审核撤回(仅供第三方代小程序调用)
* @since 2.8.30
* @param access_token access_token
* @return result
*/
public static BaseResult undocodeaudit(String access_token) {
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/wxa/undocodeaudit")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
}

/**
* 代码管理<br>
* 小程序版本回退(仅供第三方代小程序调用)
* @since 2.8.30
* @param access_token access_token
* @return result
*/
public static BaseResult revertcoderelease(String access_token) {
HttpUriRequest httpUriRequest = RequestBuilder.get()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/wxa/revertcoderelease")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.build();
return LocalHttpClient.executeJsonResult(httpUriRequest,BaseResult.class);
}

/**
* 代码管理<br>
Expand Down Expand Up @@ -364,7 +397,55 @@ public static BufferedImage getwxacodeunlimit(String access_token,Getwxacodeunli
}
return null;
}


/**
* 获取小程序码 B<br>
* 适用于需要的码数量极多,或仅临时使用的业务场景<br>
* 注意:通过该接口生成的小程序码,永久有效,数量暂无限制。用户扫描该码进入小程序后,将统一打开首页,开发者需在首页根据获取的码中 scene 字段的值,再做处理逻辑。
* @since 2.8.30
* @param access_token access_token
* @param getwxacodeunlimit getwxacodeunlimit
* @return WxaCodeResult WxaCodeResult
*/
public static WxaCodeResult getwxacodeunlimitresult(String access_token,Getwxacodeunlimit getwxacodeunlimit){
String json = JsonUtil.toJSONString(getwxacodeunlimit);
HttpUriRequest httpUriRequest = RequestBuilder.post()
.setHeader(jsonHeader)
.setUri(BASE_URI + "/wxa/getwxacodeunlimit")
.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
.setEntity(new StringEntity(json,Charset.forName("utf-8")))
.build();
CloseableHttpResponse httpResponse = LocalHttpClient.execute(httpUriRequest);
try {
int status = httpResponse.getStatusLine().getStatusCode();
WxaCodeResult wxaCodeResult;
byte[] bytes = null;
if (status == 200) {
bytes = EntityUtils.toByteArray(httpResponse.getEntity());
BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream(bytes));
if(bufferedImage != null) {
wxaCodeResult = new WxaCodeResult();
wxaCodeResult.setBufferedImage(bufferedImage);
return wxaCodeResult;
}
}
if (status >= 200 && status < 300 && bytes != null) {
String str = new String(bytes, StandardCharsets.UTF_8);
wxaCodeResult = JsonUtil.parseObject(str, WxaCodeResult.class);
return wxaCodeResult;
}
} catch (IOException e) {
logger.error("", e);
} finally {
try {
httpResponse.close();
} catch (IOException e) {
logger.error("", e);
}
}
return null;
}

/**
* 附近 添加地点
* @since 2.8.18
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/weixin/popular/bean/wxa/WxaCodeResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package weixin.popular.bean.wxa;

import weixin.popular.bean.BaseResult;

import java.awt.image.BufferedImage;

public class WxaCodeResult extends BaseResult {

private BufferedImage bufferedImage;

public BufferedImage getBufferedImage() {
return bufferedImage;
}

public void setBufferedImage(BufferedImage bufferedImage) {
this.bufferedImage = bufferedImage;
}
}

0 comments on commit a576d1e

Please sign in to comment.