收藏
回答

调用查询微信商家券报错(PS这两个错误都是签名问题吗?)。第一个方法是能调通的,报错为了对比两个错误

{

    public static  void getParams() {

        /** 获取连接客户端工具 **/
        CloseableHttpClient httpClient = HttpClients.createDefault();
        String entityStr = null;
        CloseableHttpResponse response = null;
        try {

            /** 由于GET请求的参数都是拼装在URL地址后方,所以我们要构建一个URL,带参数 **/
            URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/certificates");

            /** 根据带参数的URI对象构建GET请求对象 **/
            HttpGet httpGet = new HttpGet(uriBuilder.build());

            /** 添加请求头信息 **/
            httpGet.addHeader("Accept", "application/json");
            httpGet.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36");
            httpGet.addHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 mchid=\"xxxxxx\",nonce_str=\"593BEC0C930BF1AFEB40B4A08C8FB242\",signature=\"cBXrETRvSxZe8K4NRZU4Cdf+qObGQbqk3X14GS1N9zLOkufohRAygWjdyBbHRXV4JFWpEcI58/77Kb38PP0bfem2EO7q4V4PsTz4AmTFLoFaIkYodmetBdTu179ELRya3uWY5XZ3n/w/+M1T4/H/XBl1zUQoAtPIfLQ==\",timestamp=\"1591701914\",serial_no=\"xxxxxxxxxx\"");
            /** 传输的类型 **/
            httpGet.addHeader("Content-Type", "application/json");

            /** 执行请求 **/
            response = httpClient.execute(httpGet);

            /** 获得响应的实体对象 **/
            HttpEntity entity = response.getEntity();

        /** 打印响应内容 **/
        System.out.println(entityStr);

    }

    public static  void  key(){

            /** 获取连接客户端工具 **/
            CloseableHttpClient httpClient = HttpClients.createDefault();
            String entityStr = null;
            CloseableHttpResponse response = null;
            try {

                /** 由于GET请求的参数都是拼装在URL地址后方,所以我们要构建一个URL,带参数 **/
                URIBuilder uriBuilder = new URIBuilder("https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/1212");

                /** 根据带参数的URI对象构建GET请求对象 **/
                HttpGet httpGet = new HttpGet(uriBuilder.build());

                /** 添加请求头信息 **/
                httpGet.addHeader("Accept", "application/json");
                httpGet.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36");
                httpGet.addHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 mchid=\"xxxxxx\",nonce_str=\"MYAh4Z29RnYKLyS4peCd9TCGTTdtJ4N4IDMDvHaXg01gJqoAkbv0hUl6DkLhF6kS0FfKLnjrgULcpqIFgcQMQWxqukB8NmV7a+36KD0s0oY0iDHcn+vZcqqZ9uWe4lsJWxFGLxG8BEFNm9e23hTHmHKlncBtNqlChpncYJj6EAgZsSaoJFVF+Gnblw86KtEHPK3WBGtfGqYwzKRS7NmF/NUNmOCAi2X0FDUvneg==\",timestamp=\"1591701914\",serial_no=\"xxxxxxx\"");
                /** 传输的类型 **/
                httpGet.addHeader("Content-Type", "application/json");

                /** 执行请求 **/
                response = httpClient.execute(httpGet);

                /** 获得响应的实体对象 **/
                HttpEntity entity = response.getEntity();

         
            /** 打印响应内容 **/
            System.out.println(entityStr);

    }

}


echo -n -e \

"GET\n/v3/marketing/busifavor/stocks/?stock_id=1212\n1591701914\n593BEC030BF1AFEB40B4A08C8FB242\n\n" \

| openssl dgst -sha256 -sign apiclient_key.pem \

| openssl base64 -A


echo -n -e \

"GET\n/v3/marketing/busifavor/stocks/?1212\n1591701914\n593BEC0C930BFFEB40B4A08C8FB242\n\n" \

| openssl dgst -sha256 -sign apiclient_key.pem \

| openssl base64 -A

用这两个签名均不可以

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签