数据接口平台

https://www.juhe.cn/docs/api/id/54   使用聚合数据,是国内一觉比较好的平台

接口测试案例:--短信接口 和银行卡信息接口

package com.example.demo;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

public class Demo01 {
    public static void main(String[] str){
        card();
    }
    void sms(){
        RestTemplate restTemplate = new RestTemplate();
        System.out.println("sss");
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

        MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
        map.add("mobile", "18726175886");
        map.add("tpl_id", "12734");
        map.add("tpl_value", "#code#=4797");
        map.add("key", "#############");//密匙

        HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);

        ResponseEntity<String> response = restTemplate.postForEntity( "http://v.juhe.cn/sms/send", request , String.class );

        System.out.println(response.getBody());
    }

    static void card(){
        RestTemplate restTemplate = new RestTemplate();
        System.out.println("sss");
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);

        MultiValueMap<String, String> map= new LinkedMultiValueMap<String, String>();
        map.add("bankcard", "##############");//银行卡号
        map.add("key", "################");//密匙

        HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(map, headers);

        ResponseEntity<String> response = restTemplate.postForEntity( "http://apis.juhe.cn/bankcardcore/query", request , String.class );

        System.out.println(response.getBody());
    }

}

猜你喜欢

转载自blog.csdn.net/kevin_cat/article/details/81698319