Topics.java
파일이 데모 보내고 난 당신이 원하는 것보다 더 생각합니다 Topics API을한다 "언어"에 대한 널 포인터 예외가 발생합니다.
단순히 비디오 ID의 세부 정보를 얻으려면 Videos.list
을 확인하십시오. 페이지 하단의 API 탐색기를 사용하여 기본 요청을 생성 할 수 있습니다 (예 :
{
"kind": "youtube#videoListResponse",
"etag": "\"5g01s4-wS2b4VpScndqCYc5Y-8k/v-nx5E3jmblZ7cA3yNCjAAKmywQ\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"5g01s4-wS2b4VpScndqCYc5Y-8k/rsLwePwmFcmdkMVDPrQB20sLp1Q\"",
"id": "5vY8EWokf40",
"snippet": {
"publishedAt": "2015-06-27T03:02:46.000Z",
"channelId": "UCz0Am9KlCDydaIifIL16hfw",
"title": "Hajar Film - Sirin Hamsho | فيلم هاجر - سيرين حمشو",
...
는 자바에서 이렇게 같은 페이지에서 예 섹션을 확인하려면 다음을 반환
GET https://www.googleapis.com/youtube/v3/videos?
part=id%2Csnippet&id=5vY8EWokf40&key={YOUR_API_KEY}
.... 기본적으로 com.google.api.services.youtube.YouTube
개체를 만들고 videos().list()
으로 전화하고 VideoListResponse
을 처리해야합니다. 당신은 자바 라이브러리를 사용하는 방법에 대한 자세한 내용은 JavaDoc reference for the YouTube Data API 볼 수 있습니다
// This object is used to make YouTube Data API requests.
youtube = new YouTube.Builder(Auth.HTTP_TRANSPORT, Auth.JSON_FACTORY, credential)
.setApplicationName("youtube-cmdline-localizations-sample").build();
...
// Call the YouTube Data API's videos.list method to retrieve videos.
VideoListResponse videoListResponse = youtube.videos().
list("snippet,localizations").setId(videoId).execute();
// Since the API request specified a unique video ID, the API
// response should return exactly one video. If the response does
// not contain a video, then the specified video ID was not found.
List<Video> videoList = videoListResponse.getItems();
if (videoList.isEmpty()) {
System.out.println("Can't find a video with ID: " + videoId);
return;
}
Video video = videoList.get(0);
: 자바 # 2 예를 보면
,이 같이 입증 볼 수 있습니다.
com.google.api.services.youtube.model.VideoLocalization을 가져 오는 중에 오류가 발생했습니다. 업데이트 된 질문은 명령 줄의 스크린 샷을 참조하십시오. –
이전에 107을 참조한 176 릴리스를 추가하여 위의 내용을 수정했습니다. 그러나 여전히 193 행에 null 포인터 예외가 발생합니다. 질문은 스크린 샷으로 업데이트됩니다. –
간단한 GET 요청이 작동합니다. 감사! –