lodsve.wechat.api.base.WeChatService Maven / Gradle / Ivy
/*
* Copyright (C) 2018 Sun.Hao
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package lodsve.wechat.api.base;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.Charsets;
import com.google.common.hash.Hashing;
import lodsve.core.utils.EncryptUtils;
import lodsve.core.utils.RandomUtils;
import lodsve.core.utils.StringUtils;
import lodsve.wechat.beans.JsApiConfig;
import lodsve.wechat.config.WeChatProperties;
import lodsve.wechat.core.WeChat;
import lodsve.wechat.core.WeChatRequest;
import lodsve.wechat.core.WeChatUrl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 微信service.
*
* @author sunhao([email protected])
* @version V1.0, 16/2/23 上午11:11
*/
@Component
public class WeChatService {
private static final String SIGN_STR = "jsapi_ticket=%s&noncestr=%s×tamp=%d&url=%s";
@Autowired
private WeChatProperties properties;
public List getIps() {
String accessToken = WeChat.accessToken();
Map> ips = WeChatRequest.get(WeChatUrl.GET_IPS, new TypeReference