티스토리 뷰

반응형

19년 11월 기준.

 

package apiTest;

import java.io.BufferedReader;

import java.io.InputStreamReader;

import java.net.HttpURLConnection;

import java.net.URL;

 

public class Test {

 

public static void main(String[] args) {

String apiURL = "https://alpha-api.ticketlink.co.kr/";

String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsidGlja2V0bGluay1hcGkiXSwidXNlcl9uYW1lIjoiMTI0NjgiLCJzY29wZSI6WyJyZWFkIiwid3JpdGUiXSwiZXhwIjoxNjA4NzEyMDg4LCJhdXRob3JpdGllcyI6WyJST0xFX1VTRVIiXSwianRpIjoiMmYwMTg2NzQtYjg5My00NjdkLTg2ZjctMDY2NjE4YjdjNWMwIiwiY2xpZW50X2lkIjoibmMifQ.PVOD4E0q_hGs24hv7yV4mpHbNJ08LCj4vzqC0_bdQQgSuaK4Mu1DWckslDfnyBNoJ3EZE82uV7DvqIhDGrgWJB2t5_JXxC4XWJYB6_sfdYRMxuogUqIVzhwn60YYeWLiqTpeePTdAzNNJGX1V6U_k1GOB6pGlx8BtuowAZqDFG6-UZLfnVy9HwRT_qkJBEnNAnuXOcm20yNZSX0sWSBc8yP8wz-8KZR7uArIAh0e9mhN_U65B-M1wB6NRXH5U8K-JsJmKf735_75LPPgfDDOjSQ8r3fk1y4bVa-dTTOCwxmjeDMA13AE42nSpKnCfe1JvkO3g5bp8miDj3mgEY75Vg";

String partnerKey = "4Jd/dQWhX5ckYMU8F1u76A==";

try {

String pageURL = apiURL+"api/issue/smart-ticket";

//String pageURL = apiURL+"api/member/reserves/membership";

 

String reserveNo = "1400005530";

String membershipNo = "";

String productDate = "";

//String data = "/"+membershipNo+"/product-date/"+productDate;

String data = "/"+reserveNo;

URL url = new URL(pageURL+data);

HttpURLConnection con = (HttpURLConnection)url.openConnection();

//con.setRequestMethod("GET");

 

con.setRequestMethod("POST");

con.setRequestProperty("Authorization", "Bearer "+token);

con.setRequestProperty("partner-key", partnerKey);

con.setDoOutput(true);

 

int responseCode = con.getResponseCode();

BufferedReader br;

if(responseCode==200) {

br = new BufferedReader(new InputStreamReader(con.getInputStream()));

}

else {

System.out.println(responseCode);

br = new BufferedReader(new InputStreamReader(con.getErrorStream()));

}

String inputLine;

StringBuffer response = new StringBuffer();

while ((inputLine = br.readLine()) != null) {

response.append(inputLine);

}

br.close();

System.out.println(response.toString());

} catch (Exception e) {

System.out.println(e);

}

}

}

반응형
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
more
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함