티스토리 뷰
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);
}
}
}
'Study' 카테고리의 다른 글
VirtualBox(버추얼박스) 관련 (0) | 2024.01.21 |
---|---|
Teams(팀즈) auto formatting(자동 포맷) or auto indent(자동 들여쓰기) disable(중단) (0) | 2024.01.21 |
snoopy(스누피) 관련 (0) | 2024.01.21 |
Oracle(오라클) Korean(한글) byte(바이트) 관련 (0) | 2024.01.21 |
Sourcetree(소스트리) 관련 (0) | 2024.01.21 |