1
아래 코드를 사용하여 내 채널 통찰력 데이터 링크를 얻습니다. 어떻게 든 내 코드는 Link로 null을 반환합니다.API를 통해 YouTube 채널 통찰력 검색
/* 코드* **/
public static final String FEED_URL = "http://gdata.youtube.com/feeds/api/users/mychannelname/uploads"; //i put my channel's name in 'mychannelname'
String username = "mygmailid"; //here i entered my gmail id eg. [email protected]
String password = "mypassword";
String developerKey = "AI39si7ffVeKWbG1k37***********************************************" //developer key
YouTubeService service = new YouTubeService(username ,developerKey); //just put username instead of clientid since client id no longer available
try {
service.setUserCredentials(username, password);
} catch (AuthenticationException e) {
System.out.println("Invalid login credentials.");
System.exit(1);
}
Query query = null;
try {
query = new Query(new URL(FEED_URL));
} catch (MalformedURLException e) {
//TODO Auto-generated catch block
e.printStackTrace();
}
ChannelFeed channelFeed = null;
try {
channelFeed = service.query(query, ChannelFeed.class);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(channelFeed.getEntries() + ":");
System.out.println(" Link : "+channelFeed.getLink("http://gdata.youtube.com/schemas/2007#insight.views", "text/html") + ":");
/* ** * ****END*를 ** * ** * ***/
내가 여기 링크로 null을 얻고있다
사람이 여기에 잘못 됐는지 보려면 여기를 나를 도울 수 있습니까? 당신이 제공 한 상대 이름에 해당 링크를 찾을 수 없기 때문에
감사합니다, 마이크
안녕하세요. 문제를 조사해 주셔서 감사합니다. UI 로그인을 통해 피드에 액세스 할 수 있으며 dev 키가 올바른 것입니다. 여기 내 결과의 표준 출력입니다. System.out.println (channelFeed.getEntries() + ":")); [[email protected], [email protected], ....] System.out.println ("Link :"+ channelFeed .getLink ("http://gdata.youtube.com/schemas/2007#insight.views", "text/html") + ":"); 링크 : null : System.out.println (channelFeed); [email protected] 코드에 사용 된 'FEED_URL'이 (가) 정확한지 확인할 수 있습니까? -Mike – MikA
FEED_URL에 어떤 URL을 사용하고 싶은지 잘 모르겠지만 https : // gdata.youtube.com/feeds/api/users/default와 https : // gdata.youtube.com/feeds/api/users/username' (두 번째 것은 사용자 이름으로 대체됩니다). 통찰력 정보가 채널 정보가 아닌 사용자 프로필 정보와 함께 전송되므로 사용자가 지금 요청하는 것처럼 보일 수 있습니다. – aoi222
아래 코드를 변경했습니다. YouTubeService service = new YouTubeService (clienID, developerKey); query = new Query (새 URL ("https://gdata.youtube.com/feeds/api/users/username"))); profileFeed = service.query (query, ProfileFeed.class); System.out.println (profileFeed.getEntries() + ":")); System.out.println ("링크 :"+ profileFeed.getLink ("http://gdata.youtube.com/schemas/2007#insight.views", "text/html") + ":"); System.out.println (프로필 피드); 하지만 여전히 오류가 발생하고 있습니다. :( -Mike – MikA