資源簡介
里面的appid 和 appSecret 需要自己更換,還有與之對應的公眾號js域名配置也好配置好。其他的由我的代碼來實現。哈哈

代碼片段和文件信息
package?com.sandalice.api.controller;
import?java.io.IOException;
import?org.apache.http.HttpEntity;
import?org.apache.http.client.methods.CloseableHttpResponse;
import?org.apache.http.client.methods.HttpGet;
import?org.apache.http.impl.client.CloseableHttpClient;
import?org.apache.http.impl.client.HttpClients;
import?org.apache.http.util.EntityUtils;
import?com.alibaba.druid.support.logging.Log;
import?com.alibaba.druid.support.logging.LogFactory;
import?com.alibaba.fastjson.JSON;
public?class?HttpUtil?{
????public?static?Log?logger?=?LogFactory.getLog(HttpUtil.class);
????//get請求
????public?static?com.alibaba.fastjson.JSONobject?doGet(String?requestUrl)?{
????????CloseableHttpClient?httpClient?=?HttpClients.createDefault();
????????CloseableHttpResponse?response?=?null;
????????String?responseContent??=?null;
????????com.alibaba.fastjson.JSONobject?result?=?null;
????????try?{
????????????//創建Get請求,
????????????HttpGet?httpGet?=?new?HttpGet(requestUrl);
????????????//執行Get請求,
????????????response?=?httpClient.execute(httpGet);
????????????//得到響應體
????????????HttpEntity?entity?=?response.getEntity();
????????????//獲取響應內容
????????????responseContent??=?EntityUtils.toString(entity“UTF-8“);
????????????//轉換為map
????????????result?=?JSON.parseobject(responseContent);
????????}?catch?(IOException?e)?{
????????????logger.error(“HttpUtil=====Start“);
????????????logger.error(e.getMessage()e);
????????????logger.error(“HttpUtil=====End“);
????????}
????????return?result;
????}
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1597??2017-11-23?10:14??微信分享\HttpUtil.java
?????文件????????2500??2017-11-23?17:23??微信分享\index.jsp
?????文件???????95788??2015-04-22?15:33??微信分享\jquery.1.11.1.min.js
?????文件????????9630??2017-11-23?16:06??微信分享\jweixin-1.0.0.js
?????文件????????1747??2017-11-23?16:28??微信分享\public.js
?????文件????????8173??2017-11-23?19:30??微信分享\WxShareTest.java
評論
共有 條評論