Reputation: 5542
i'm using code below to get link for my channels insight data. somehow my code is returning null as Link.
/* 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 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**********/
i'm getting null as Link here
can anyone help me here to find what went wrong here?
Thanks, Mike
Upvotes: 1
Views: 1107
Reputation: 733
It is most likely returning null because it can't find a link corresponding to the relative name you provided. Since the channel Insight information is only available for the channel corresponding to the user you're authenticated with it could be that it is not authorizing your user to view that channels insight data, which could be because your google account is not linked with your youtube account.
I would try printing out the response you're getting back to make sure you're getting all the data you think you're getting.
Upvotes: 0