Youtube Java API. Make YouTubeService without Login
I am beginning to learn how to use the Java Youtube API, but I have run into a problem. I am following the tutorials given by Google:
http://code.google.com/apis/youtube/2.0/developers_guide_java.html
The problem is, is that you seem to need a YouTubeService object to make queries. It seems like the only way to make this is with the user logging in. How can I make queries without having the user log in?
YouTubeService service = new YouTubeService(); //???? How do I make a proper YouTubeService without login. There is no constructor without and parameters.
String search = "Dubstep";
try {
YouTubeQuery query = new YouTubeQuery(new URL("http://gdata.youtube.com/feeds/api/videos"));
query.setOrderBy(YouTubeQuery.OrderBy.RELEVANCE);
query.setFullTextQuery(search);
query.setSafeSearch(YouTubeQuery.SafeSearch.NONE);
VideoFeed videoFeed = service.qu开发者_如何学Goery(query, VideoFeed.class);
printVideoFeed(videoFeed, true); // Eclipse also doesn't recognize this method.
} catch (MalformedURLException e) {
e.printStackTrace();
}
I am really confused by this, and I really need this help.
Thanks!
What is your problem? There is a constructor where you can pass your application name:
http://code.google.com/apis/gdata/javadoc/com/google/gdata/client/youtube/YouTubeService.html
Just call this:
YouTubeService service = new YouTubeService("The name of my application");
精彩评论