使用 Google Youtube API
我正在努力玩!应用程序通过 GData API 从 Youtube 获取数据。按照 Youtube 指南,我添加
import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
到文件顶部,然后创建了我的课程,
public class Videos extends Controller {
//...Irrelevant stuff...
public static void create(@Required String video_id) {
if (validation.hasErrors()) {
render("Videos/submit.html");
}
YouTubeService service = new YouTubeService("app", "abcd");
String videoEntryURL = "http://gdata.youtube.com/feeds/api/videos/"+video_id;
VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL), VideoEntry.class);
System.out.println(videoEntry.getTitle().getPlainText());
}
//...Irrelevant stuff...
}
我从 Play 中收到以下错误
编译错误
无法编译文件/app/controllers/Videos.java。错误 提出的是: com.google.gdata.client.media.MediaService 类型不能 得到解决。它是从所需的 .class 文件中间接引用的 /app/controllers/Videos.java(第 40 行左右)
40: VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL), VideoEntry.class);
在浏览器中和
play.exceptions.CompilationException:类型 无法解析 com.google.gdata.client.media.MediaService。这是 从所需的 .class 文件间接引用 play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246) 在 org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:474) 在 play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:278) 在 play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:412) 在 play.Play.start(Play.java:485) 处 play.Play.detectChanges(Play.java:599) at 在 Invoker.HTTP 上玩.Invoker$Initation.init(Invoker.java:186) 请求(播放!)
从命令行
。我最近才开始使用 Play!但这个错误让我难住了 =/
我已将 GData api 中的两个必需的库添加到我的 Play 的 /lib/ 文件夹中!应用程序,我所遵循的 GData API 指南位于此处
I'm trying to get a Play! app to get data from Youtube via the GData API. Following the Youtube guide I added
import com.google.gdata.client.*;
import com.google.gdata.client.youtube.*;
import com.google.gdata.data.*;
import com.google.gdata.data.geo.impl.*;
import com.google.gdata.data.media.*;
import com.google.gdata.data.media.mediarss.*;
import com.google.gdata.data.youtube.*;
import com.google.gdata.data.extensions.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.io.File;
import java.net.URL;
To the top of my file then created my class
public class Videos extends Controller {
//...Irrelevant stuff...
public static void create(@Required String video_id) {
if (validation.hasErrors()) {
render("Videos/submit.html");
}
YouTubeService service = new YouTubeService("app", "abcd");
String videoEntryURL = "http://gdata.youtube.com/feeds/api/videos/"+video_id;
VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL), VideoEntry.class);
System.out.println(videoEntry.getTitle().getPlainText());
}
//...Irrelevant stuff...
}
I'm getting the following error from Play
Compilation error
The file /app/controllers/Videos.java could not be compiled. Error
raised is : The type com.google.gdata.client.media.MediaService cannot
be resolved. It is indirectly referenced from required .class files In
/app/controllers/Videos.java (around line 40)40: VideoEntry videoEntry = service.getEntry(new URL(videoEntryURL),
VideoEntry.class);
In the browser and
play.exceptions.CompilationException: The type
com.google.gdata.client.media.MediaService cannot be resolved. It is
indirectly referenced from required .class files at
play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:246)
at
org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:474)
at
play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:278)
at
play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:412)
at play.Play.start(Play.java:485) at
play.Play.detectChanges(Play.java:599) at
play.Invoker$Invocation.init(Invoker.java:186) at Invocation.HTTP
Request(Play!)
From the command line.
I've only recently started using Play! but this error has me stumped =/
I've added the two required librarys from the GData api to the /lib/ folder of my Play! app, the guide I'm following for the GData API is here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
com.google.gdata.client.media.MediaService 位于 gdata-media-[版本].jar 中。在我的项目中,我有五个 gdata jar:gdata-base、gdata-client、gdata-media、gdata-youtube 和 gdata-core。
com.google.gdata.client.media.MediaService is in the gdata-media-[version].jar. In my projects, I have five gdata jars: gdata-base, gdata-client, gdata-media, gdata-youtube, and gdata-core.