1.1
輸入com.alibaba.fastjson.JSON。
輸入com.alibaba.fastjson.JSONObject。
輸入org.springframework.http.ResponseEntity。
輸入org.springframework.web.client.RestTemplate。
1.2
公共の静的な文字列getTemplateMessageSend(RestTemplate restTemplate){
文字列accessTokenUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential"。
文字列appIDが= "WX"。
文字列=「90F」秘密。
文字列パス= String.Formatの( "%S&APPID =%S&秘密=%のS"、accessTokenUrl、appIDが、秘密)。
ResponseEntityの<string>エンティティ= restTemplate.getForEntity(パス、String.class)。
JSONObject responseObj = JSON.parseObject(entity.getBody())。
ストリングaccess_tokenは= responseObj.getString( "access_tokenは")。
access_tokenは返します。
}
1.3