Friday, January 13, 2012

[YouTube-API] Retrieving YouTube insight data through API (Java)

Hi,

i'm using code below to get link for getting my channels insight data. but i'm getting null as Link.
can anyone help me to find whats wrong here?

/****** code**********/

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
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*********************/

i'm getting null as Link here

can anyone help me here to find what went wrong here?

Thanks,
Mike

--
You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To view this discussion on the web visit https://groups.google.com/d/msg/youtube-api-gdata/-/aLp9AIns_gAJ.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.

No comments:

Post a Comment