일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 스테이블코인
- Cars
- Investing
- Digital Marketing
- 암호화폐규제
- 프로그래머스
- coins
- 파이썬
- 비트코인
- Baekjoon
- SECS/GEM
- finance & economics
- SECS
- Gem
- python
- ai이미지변환
- 암호화폐시장
- java
- Spring JPA
- C++
- 암호화폐투자
- CS
- 암호화폐
- 백준
- programmers
- spring boot
- Spring
- c
- 지브리필터
- 자바
Archives
- Today
- Total
비버놀로지
[Spotify 스포티파이] 6. Spring Boot 기본 Code 본문
반응형
아래의 코드는 기본 코드이다.
거의 모든 클래스에서 사용이 될것이다.
그리고 setAccessToken("여기는 내가 발급 받은 토큰")을 넣어주어야 한다.
아래의 getSometingRequest를 활용해 가수 ID, 앨범 ID, 노래 ID 어떤 것을 넣든 불러올 수 있다.
// For all requests an access token is needed
SpotifyApi spotifyApi = new SpotifyApi.Builder()
.setAccessToken("taHZ2SdB-bPA3FsK3D7ZN5npZS47cMy-IEySVEGttOhXmqaVAIo0ESvTCLjLBifhHOHOIuhFUKPW1WMDP7w6dj3MAZdWT8CLI2MkZaXbYLTeoDvXesf2eeiLYPBGdx8tIwQJKgV8XdnzH_DONk")
.build();
// Create a request object with the optional parameter "market"
final GetSomethingRequest getSomethingRequest = spotifyApi.getSomething("qKRpDADUKrFeKhFHDMdfcu")
.market(CountryCode.SE)
.build();
void getSomething_Sync() {
try {
// Execute the request synchronous
final Something something = getSomethingRequest.execute();
// Print something's name
System.out.println("Name: " + something.getName());
} catch (Exception e) {
System.out.println("Something went wrong!\n" + e.getMessage());
}
}
void getSomething_Async() {
try {
// Execute the request asynchronous
final Future<Something> somethingFuture = getSomethingRequest.executeAsync();
// Do other things...
// Wait for the request to complete
final Something something = somethingFuture.get();
// Print something's name
System.out.println("Name: " + something.getName());
} catch (Exception e) {
System.out.println("Something went wrong!\n" + e.getMessage());
}
}
반응형
'OPEN API 활용' 카테고리의 다른 글
[Spotify 스포티파이] 8. Spring Boot 가수 검색 (2) | 2021.03.25 |
---|---|
[Spotify 스포티파이] 7. Spring Boot 토큰 발행 (0) | 2021.03.25 |
[Spotify 스포티파이] 5. Spring Boot 사전준비 (0) | 2021.03.25 |
[Spotify 스포티파이] 4. Spotify Data 추출 (0) | 2021.03.09 |
[Spotify 스포티파이] 3. Spotify OPEN API 특정 artist의 top 10 playlist 가져오기 (0) | 2021.03.09 |
Comments