package com.winsun.smsUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * 令牌获取
 */
public class GetAccessToken {
    
	public static void main(String[] args) {
		
		// String url = "http://183.61.185.118:8082/sendApi/auth/getAccessToken"; //测试
		
		String   url = "https://ytx.21cn.com/sendApi/auth/getAccessToken";//生产
		
		String appKey = "6SXyMB2IG";
		String appSecret = "92a1861c7a94a49fb165a22cb0d7dfad14196c25";
		String version = "2.0v";
		String format = "json";
		String clientType = "10001";
		Map<String,String> requestData = new HashMap<>();
		requestData.put("timeStamp",String.valueOf(System.currentTimeMillis()));
		
		RequestParasUtil.setParas(requestData,appKey,appSecret,version,format,clientType);
		
		try {
			String test = HttpUtil.httpPostMethodNoReTryWithStr(url,requestData);
			System.out.println(test);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
    
    public String getAccessToken(){
    	  String   url = "https://ytx.21cn.com/sendApi/auth/getAccessToken";//生产

          String appKey = "6SXyMB2IG";
          String appSecret = "92a1861c7a94a49fb165a22cb0d7dfad14196c25";
          String version = "2.0v";
          String format = "json";
          String clientType = "10001";
          Map<String,String> requestData = new HashMap<>();
          requestData.put("timeStamp",String.valueOf(System.currentTimeMillis()));
             System.out.println(requestData);

          RequestParasUtil.setParas(requestData,appKey,appSecret,version,format,clientType);

          try {
              System.out.println(requestData);
              String accesstoken = HttpUtil.httpPostMethodNoReTryWithStr(url,requestData);
              System.out.println(accesstoken);
              return accesstoken;
          } catch (Exception e) {
              e.printStackTrace();
          }
          return null;
    }
}
