java.lang.Object
com.abasecode.opencode.pay.plugin.wechatpay.util.WechatHttp

public class WechatHttp extends Object
作者:
Jon e-mail: ijonso123@gmail.com url: Jon's blog url: project github url: AbaseCode.com
  • 构造器详细资料

    • WechatHttp

      public WechatHttp()
  • 方法详细资料

    • httpGet

      public static <T> T httpGet(String url, String json, Class<T> t) throws Exception
      发起HTTP请求,并返回实体
      类型参数:
      T - 目标实体
      参数:
      url - 目标URL
      json - 参数(GET参数)
      t - 目标实体.class
      返回:
      目标实体
      抛出:
      Exception
    • httpPost

      public static <T> T httpPost(String url, String json, Class<T> t) throws Exception
      发起Post请求
      类型参数:
      T - 目标实体
      参数:
      url - 目标URL
      json - 参数(POST参数)
      t - 目标实体.class
      返回:
      目标实体
      抛出:
      Exception
    • getTbyResult

      private static <T> T getTbyResult(Class<T> t, int statusCode, String jsonString, T instance)
      将JSON文本转换成目标实体类
      类型参数:
      T - 目标类
      参数:
      t - 目标实体
      statusCode - http状态码
      jsonString - JsonString
      instance - 实例
      返回:
      目标类
    • getPostResponse

      private static org.apache.http.HttpResponse getPostResponse(String url, String json) throws Exception
      获得POST方法返回body
      参数:
      url -
      json -
      返回:
      HttpResponse
      抛出:
      Exception
    • httpToken

      private static String httpToken(String method, String urlString, String body) throws Exception
      get http token
      参数:
      method - GET POST
      urlString - URL
      body - Post method with JSON, Get method with ""
      返回:
      String
      抛出:
      Exception
    • getGetResponse

      private static org.apache.http.HttpResponse getGetResponse(String url, String json) throws Exception
      获得GET方法返回body
      参数:
      url - url
      json - json
      返回:
      HttpResponse
      抛出:
      Exception
    • httpSign

      public static String httpSign(String method, String urlString, String body, long timestamp, String nonceStr) throws Exception
      Get http sign
      参数:
      method - GET POST
      urlString - URL
      body - Post method with JSON, Get method with ""
      timestamp - timestamp
      nonceStr - Random String
      返回:
      String
      抛出:
      Exception
    • getJsapiSign

      public static String getJsapiSign(String appId, String timestamp, String nonceStr, String packages) throws Exception
      JSAPI SIGN(小程序,公众号通用)
      参数:
      timestamp - timestamp
      nonceStr - Random String
      packages - body
      返回:
      String
      抛出:
      Exception
    • getSign

      public static String getSign(String signatureStr) throws Exception
      get sign with RSA
      参数:
      signatureStr -
      返回:
      String
      抛出:
      Exception