详细步骤在微信开发文档中已经写得很明白,开发前仔细看下就好!一定要仔细看。
再次记录下代码,下次可以直接拿来使用! 根据需求进行微调!
import org.apache.commons.lang.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpUriRequest; import org.apache.http.entity.ContentType; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import java.io.IOException; import java.nio.charset.Charset; import java.util.Date; import java.util.HashMap; @Service public class WeChatLoginServiceImpl implements WeChatLoginService { private