问题
I am creating an app using YouTube API. Here I want to list all the channel related to an E-mail id so I have written this below code. The problem with this code is that it is returning only one Channel (The default one) but i want a list of all channels.
Here is the code:
YouTube youTube = new YouTube.Builder(new NetHttpTransport(), new JacksonFactory(), new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {}
}).setApplicationName("YouTube").build();
try {
final YouTube.Channels.List list = youTube.channels().list("snippet,id");
list.setForUsername("USER_NAME");
list.setKey("API_KEY");
new Thread(new Runnable() {
@Override
public void run() {
try{
ChannelListResponse response = list.execute();
List<Channel> channelList = response.getItems();
Log.wtf("totalChannel", channelList.size()+"");
for (Channel channel: channelList){
Log.wtf("channel", channel.getSnippet().getTitle().toString());
Log.wtf("id", channel.getId().toString());
}
}catch (Exception ex){Log.wtf("exception", ex.toString());}
}
}).start();
}catch (Exception ex){Log.wtf("exception", ex.toString());}
来源:https://stackoverflow.com/questions/46891136/youtube-channels-list-from-youtube-api-v3-returning-only-one-channel-in-android