package hls.plugin.weixin.fuwu;

import hls.plugin.weixin.common.HttpUtil;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

public class ServiceUtil
{
  public static String getAccessCodeURL(String appid, String redirect_uri, String state)
  {
    String mutiurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_base&state=" + state + "#wechat_redirect";
    return mutiurl;
  }

  public static void getAccessCodeRuquest(String appid, String redirect_uri, String state)
  {
    String redirect_urito = "";
    try {
      redirect_urito = URLEncoder.encode(redirect_uri, "utf-8");
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
    String requestUrl = getAccessCodeURL(appid, redirect_urito, state);
    HttpUtil.httpRequestUrl(requestUrl, "GET");
  }
}