Java Google 데이터 API를 사용하여 YouTube에서 비디오를 업로드하고 싶습니다. 비디오를 업로드하기 위해 Google Data Api 문서에서 다음 코드를 받았습니다. 클라이언트 ID 및 Porduct 키에서이 코드를 변경해야합니다. 나는 followinf 메서드를 사용하여 인증합니다.자바 Google 유튜브 데이터 API :: 무단
YouTubeService service = new YouTubeService (clientID, developer_key);
클라이언트 키 wasy와 함께 시도 내 Google 이메일 ID,
- 에만 제공되는 사용자 이름 전자, g이다. "sampleuser"
- 또는 전체 Gmail ID. "[email protected]"또는 "[email protected]"
내가
하지만 난 항상 다음과 같은 예외를 가지고 언급 한 "[email protected]"로 내 Google 메일 ID를 로그인하여 개발자 키를 가지고
com.google.gdata.util.AuthenticationException: Unauthorized
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
at com.google.gdata.client.media.MediaService.insert(MediaService.java:400)
at YouTube.videoUpload(YouTube.java:115)
at YouTube.main(YouTube.java:43)
여기에 해결책을 찾을 수없는 업로드
YouTubeService service = new YouTubeService("[email protected]",
"fakegoogleapplicationidjsuttoshowthatimgivingidhere");
// YouTubeService service = new YouTubeService("My Application");
VideoEntry newEntry = new VideoEntry();
YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup();
mg.setTitle(new MediaTitle());
mg.getTitle().setPlainTextContent("My Test Movie");
mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME, "Autos"));
mg.setKeywords(new MediaKeywords());
mg.getKeywords().addKeyword("cars");
mg.getKeywords().addKeyword("funny");
mg.setDescription(new MediaDescription());
mg.getDescription().setPlainTextContent("My description");
mg.setPrivate(false);
mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "mydevtag"));
mg.addCategory(new MediaCategory(YouTubeNamespace.DEVELOPER_TAG_SCHEME, "anotherdevtag"));
newEntry.setGeoCoordinates(new GeoRssWhere(37.0,-122.0));
// alternatively, one could specify just a descriptive string
// newEntry.setLocation("Mountain View, CA");
MediaFileSource ms = new MediaFileSource(new File("D:\\maths.mp4")
, "video/quicktime");
newEntry.setMediaSource(ms);
// "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
String uploadUrl =
"http://uploads.gdata.youtube.com/feeds/api/users/default/uploads";
try {
VideoEntry createdEntry = service.insert(new URL(uploadUrl), newEntry);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
도와주세요 비디오, 내 코드입니다. 당신이 그렇게 응답을 much..looking 감사