概述
public JsonResult getScheme() {
JsonResult result = new JsonResult();
String requestUrl = "https://api.weixin.qq.com/wxa/generatescheme?access_token=ACCESS_TOKEN";
String Access_Token = wxAPIService.getThisAccessToken();
requestUrl=requestUrl.replace("ACCESS_TOKEN", Access_Token);
OkHttpClient client = new OkHttpClient().newBuilder().build();
MediaType mediaType = MediaType.parse("application/json");
okhttp3.RequestBody body = okhttp3.RequestBody.create(mediaType, "{rn "jump_wxa":rn {rn "path": "page/reward/enterPrize/index",rn "query": ""rn },rn "is_expire":falsern}");
Request request = new Request.Builder()
.url(requestUrl)
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
try {
Response response = client.newCall(request).execute();
if (response != null) {
if (response.body() != null) {
String s = new String(response.body().bytes());
JSONObject jsonResult = JSON.parseObject(s);
if (jsonResult != null) {
System.out.println(jsonResult);
int errorCode = jsonResult.getInteger("errcode");
String errorMessage = jsonResult.getString("errmsg");
if (errorCode == 0) {
result.setData(jsonResult);
result.setMessage("Send Success");
result.setState(0);
} else {
result.setMessage("获取Scheme失败:" + errorCode + "," + errorMessage);
result.setState(1);
}
} else {
result.setMessage("获取Scheme失败:jsonResult为空");
result.setState(1);
}
return result;
}
}
}catch (Exception e){
result.setMessage(e.getMessage());
result.setState(1);
}
return result;
}
最后
以上就是称心天空为你收集整理的URL Scheme打开小程序的全部内容,希望文章能够帮你解决URL Scheme打开小程序所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复