Skip to content

SDK 下载

JAVA 版本

请求示例

JAVA
package xxx.zBank;

import com.alibaba.fastjson.JSONObject;
import org.jeecg.common.nethttp.HttpClientCommon;
import org.jeecg.common.third.zBank.eAccout2.Digester;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

public class HBTest {
    public  static String  key = "xxx" ;//开发者标识
    public  static String  secret = "xxxxxx";//开发者秘钥
    public static void main(String[] args) {
        String api = "https://api.hbsk.com/";
        String url = api+"/share/holder/query"; //获取分账方详情接口
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("key", key);
        long time = System.currentTimeMillis()/1000L;
        jsonObject.put("time",time);
        JSONObject contentJSObObject = new JSONObject();
        contentJSObObject.put("code","H6463493"); //分账方编码
        String sign = null;
        try {
             sign = Digester.sha256((contentJSObObject.toJSONString()+secret).getBytes("UTF-8"));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println(sign.toLowerCase());
        jsonObject.put("sign",sign.toLowerCase());
        jsonObject.put("data",contentJSObObject.toJSONString());
        System.out.println(contentJSObObject.toJSONString());
        System.out.println(jsonObject.toJSONString());
        String result = HttpClientCommon.doPost(url,jsonObject.toJSONString());
        System.out.println(result);
        System.out.println(JSONObject.parseObject(result).toJSONString());

    }



    //直接上传文件到慧分账,返回文件code
    public JSONObject uploadFile(MultipartFile multipartFlies) throws IOException {
        HttpRequest httpRequest = HttpRequest.post(upFile)
        .form("files", new InputStreamResource(multipartFiles.getInputStream(), multipartFiles.getOriginalFilename()))
        .form("data", "{}");

        sign(httpRequest);
        String jsonBody = httpRequest.execute().body();
        JSONObject jsonObject = JSON.parsObject(jsonBody);

        if(jsonObject.getIntValue("code")== 0){
            //成功
            return jsonObject.getJSONObject("data");
        }else{
            throw new IOException("上传文件到慧分账错误:"+jsonObject.toJSONString());
        }
    }
}

SDK 点击下载