2

I am trying to get all the channels of user via using Youtube data api v3 in android, i am using Channels: list https://developers.google.com/youtube/v3/docs/channels/list#http-request get the all channels ,

public static void getChannelID(YouTube youtube){
        try {
            Log.i(MainActivity.APP_NAME, "Requesting ChannelID.");

             com.google.api.services.youtube.YouTube.Channels.List Channel = youtube.channels().list("id,snippet,contentDetails");
             Channel.setMine(true);

            // In the API response, only include channel information needed
             // for this use case.
             Channel.setFields("items/contentDetails, items/id, items/snippet");
             // List request is executed and list of broadcasts are returned
             ChannelListResponse returnedListResponse = Channel.execute();
            // Since the API request specified a unique channel ID, the API
             // response should return exactly one channel. If the response does
             // not contain a channel, then the specified channel ID was not found.
             List<Channel> channelList = returnedListResponse.getItems();

             Log.e("=========channelList.size=========", ""+channelList.size());

             for (int i = 0; i < channelList.size(); i++) {
                 if (channelList != null) {
                     // The user's default channel is the first item in the list.
                     String channelId = channelList.get(i).getId();
                     Log.e("=========channelId=========", ""+channelId);
                     Log.e("=========getContentDetails=========", ""+channelList.get(i).getContentDetails());
                     Log.e("=========getSnippet=========", ""+channelList.get(i).getSnippet());
                     //Log.i("getStatus", ""+channelList.get(i).getStatus());
                     //Log.i("getKind", ""+channelList.get(i).getKind());
                     //USE FOR LOOP HERE TO RETRIEVE ALL CHANNELS 
                 }
             }

        }catch (GoogleJsonResponseException e) {
            Log.e("GoogleJsonResponseException", e.toString());
            System.err.println("GoogleJsonResponseException code: "
                    + e.getDetails().getCode() + " : "+ e.getDetails().getMessage());
            e.printStackTrace();

        }catch (IOException e) {
            System.err.println("IOException: " + e.getMessage());
            e.printStackTrace();
        }  catch (Throwable t) {
            System.err.println("Throwable: " + t.getMessage());
            t.printStackTrace();
        }
    }

Currently, I have configured 2 channels under my account. But the above line always prints the channel count as 1. Any idea on how to get all channel details using API?

Achin
  • 1,252
  • 4
  • 28
  • 63
  • Have you tried using the API playground yet to make sure it returns the expected results? Just to make sure it's not something outside your code. – Kenny Apr 02 '16 at 15:18
  • i think there is an API limit , have a look at this thread https://code.google.com/p/gdata-issues/issues/detail?id=6476&q=Channels.List&colspec=API%20ID%20Type%20Status%20Priority%20Stars%20Summary – Achin Apr 04 '16 at 04:58
  • 1
    Did you get a solution for this? – Shubham A. Jun 23 '16 at 08:13
  • no , actually you can get all channel details using API – Achin Jun 24 '16 at 04:10

0 Answers0