数据接口平台

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

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 map= new LinkedMultiValueMap();
        map.add("mobile", "18726175886");
        map.add("tpl_id", "12734");
        map.add("tpl_value", "#code#=4797");
        map.add("key", "#############");//密匙

        HttpEntity> request = new HttpEntity>(map, headers);

        ResponseEntity 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 map= new LinkedMultiValueMap();
        map.add("bankcard", "##############");//银行卡号
        map.add("key", "################");//密匙

        HttpEntity> request = new HttpEntity>(map, headers);

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

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

}

你可能感兴趣的:(接口平台之聚合数据)