我正在开发一个Android应用程序,它使用gdata-java-client下载文档仅供显示.到目前为止,我有一个应用程序,它使用服务进行身份验证并显示用户文档列表.当用户选择文档时,对文档本身进行另一个查询.对txt,html,rtf和doc文件的请求很有效,但是当我以.csv或.xsl格式请求电子表格时,结果是意外的.
我正在使用HTTPResponse对象来存储HTTPRequest的结果.当我以.csv或.xsl格式请求文档时,HTTPResponse.parseAsString()方法会生成一个完整的html页面,该页面似乎是Google Docs主页.听起来很奇怪,但结果是登录页面的实际html.HTTPResponse.getStatusMessage返回200.
好像我在这里错过了一些简单的东西.是否有HTTPResponse的另一个属性包含.csv数据?
我很确定我使用正确的uri来下载电子表格,因为它可以在我通过浏览器下载时使用.在任何情况下,这是一个例子uri:
https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=0AsE_6_YIr797dHBTUWlHMUFXeTV4ZzJlUGxWRnJXanc&exportFormat=csv
Run Code Online (Sandbox Code Playgroud)
在此先感谢任何帮助:)
java android google-api-java-client google-drive-android-api google-sheets-api
从谷歌服务器验证谷歌文档后,我做了一个简单的getResponse,但我收到了400 Bad Request.我无法理解我哪里出错了.示例代码如下
private void executeRefreshAlbums() {
HttpRequest request = transport.buildGetRequest();
request.url = GoogleDocsUrl.forDefaultPrivateFull();
System.out.println("URL = "+request.url);
try {
HttpResponse response = request.execute();
System.out.println("Response = "+response.getContent());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
sysout打印正确的URL作为
03-12 17:36:59.573: INFO/System.out(451): URL = https://docs.google.com/feeds/default/private/full
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我明白了
03-12 17:43:41.360: WARN/System.err(3958): com.google.api.client.http.HttpResponseException: 400 Bad Request
03-12 17:43:41.415: WARN/System.err(3958): at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:209)
03-12 17:43:41.415: WARN/System.err(3958): at com.example.Test.executeRefreshAlbums(Test.java:198)
03-12 17:43:41.415: WARN/System.err(3958): at com.example.Test.authenticated(Test.java:190)
03-12 17:43:41.415: WARN/System.err(3958): at com.example.Test.authenticatedClientLogin(Test.java:156)
03-12 17:43:41.415: WARN/System.err(3958): at com.example.Test.access$1(Test.java:153)
03-12 …Run Code Online (Sandbox Code Playgroud) java android httpresponse google-docs google-api-java-client
浏览rfc2445后,我仍然无法设置事件的重复发生.
private String[] days = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
private String rrule = "RRULE:FREQ=WEEKLY;WKST=MO;BYDAY=";
private Event createdEvent;
...
Event event = new Event();
StringBuilder sb = new StringBuilder();
sb.append(rrule);
sb.append(days[startTime.get(java.util.Calendar.DAY_OF_WEEK)-1]);
event.setSummary("HELLO WORLD");
event.setLocation("");
DateTime start = new DateTime(startTime.getTime(), TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endTime.getTime(), TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
//Setting Recurrence
ArrayList<String> recur = new ArrayList<String>();
recur.add(sb.toString());
event.setRecurrence(recur);
createdEvent = cal.events().insert("primary", event).execute(); //line 167
Run Code Online (Sandbox Code Playgroud)
运行上面的代码后,我一直收到这个错误(注意:如果我省略指定重复,一切正常,但显然这会使事件单一发生):
01-13 19:26:17.190: WARN/System.err(5732): com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 …Run Code Online (Sandbox Code Playgroud) java recurrence android google-calendar-api google-api-java-client
我正在尝试使用google api客户端库发送帖子请求,但无法成功.
这是我正在使用的片段
UrlEncodedContent urlEncodedContent = new UrlEncodedContent(paramMap); //paramMap contains email and password keypairs
HttpRequest request = httpRequestFactory.buildPostRequest(new GenericUrl(Constants.PHP_SERVICE_BASE_PATH + mPath) , urlEncodedContent);
String response = request.execute().parseAsString();
Run Code Online (Sandbox Code Playgroud)
我没有得到预期的回应.我认为这是因为邮政参数,即电子邮件和密码没有以正确的格式发送.我需要用JSON发送它们.
注意:我没有将该库用于Google Web服务.
我正在尝试获取文件的缩略图但是收到错误404,返回驱动器的URL在某些文件中是这样的
但在其他人是
最后一个是来自picasa并且有效,所以显然有效的网址来自picasa,我怎样才能获得最后一个文件的网址?
我在Google API Java客户端库版本1.12.0-beta中找出一个看似简单的任务时遇到了麻烦.我可以使用OAuth2进行身份验证,并可以检索和操作我的应用程序所需的Google云端硬盘部分.但是,我想遵循Google 最佳做法,并在我的应用顶部显示基本用户信息.
我搜索了谷歌提供的文件迷宫,并搜索了许多其他网站,似乎无法找到我需要的东西.我查看了最佳实践页面上建议的Userinfo API.据我所知,它应该是我正在使用的java客户端的一部分,但事实并非如此.我甚至找到了一个完整的方法示例,概述了我如何获取用户信息.它引用的类 - Userinfo - 似乎不是我正在使用的客户端库中包含的任何库的一部分.我进一步搜索,看看我是否错过了包含OAuth服务Java客户端的单独下载.
我认为我遇到的主要问题是找到当前版本的Java客户端库的相关信息.还有其他人遇到过这个问题吗?我非常感谢有关如何获取基本用户信息的任何指示.
谢谢你的帮助.
我正在尝试编写一个使用Google自定义搜索API来检索搜索结果的Java程序.但是,作为API的首次使用者,网站上的文档非常混乱 - 通过连接到谷歌API链接来检索结果,如:
(然后一旦连接,你如何显示结果?使用BufferedReader给我一个403错误)
...或者您是否需要下载库并使用他们的GoogleCustomSearch类:
?我有googleux-customsearch jar(来自http://blog.lux-medien.com/2011/08/google-custom-search-java-implementation/)并将其集成到Eclipse中,但我不太确定是什么导入我应该使用这些语句来使用这些类(同样是第一次使用者).
我也不太确定Java客户端,REST API和JSON API之间的区别(它们都是一样的吗?),如Google Custom Search API网站上详述的那样......任何人都可以澄清一下吗?谢谢!
我的maven项目使用Directory API Client Library for Java,我需要将它作为依赖项包含在内.但是在Directory API Client Library for Java页面中,当我选择maven作为我的构建环境时,在Add Library to Your Project标题下,它总是显示,
"将以下内容添加到pom.xml文件中:
该库正在上传到中央Maven存储库.请几个小时后再回来看看."
过去几周.
由于我在另一个项目中使用了谷歌驱动器依赖,如下所示,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev60-1.13.2-beta</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我试着这样做,包括,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-directory</artifactId>
<version>v1-rev28-1.17.0-rc</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
但它没有奏效.
而对于重新编码,我的pom也有以下存储库,
<repository>
<id>google-api-services</id>
<url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
</repository>
Run Code Online (Sandbox Code Playgroud)
使用Directory API Client Library for Java的正确maven依赖是什么.
真的卡在这里了。该代码是根据Google提供的示例构建的:
public static void main(String[] args) {
try {
HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
httpTransport, jsonFactory, CLIENT_ID, CLIENT_SECRET, Arrays.asList(DriveScopes.DRIVE))
.setAccessType("online")
.setApprovalPrompt("auto")
.build();
String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).build();
System.out.println("Please open the following URL in your browser then type the authorization code:");
System.out.println(" " + url);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String code = br.readLine();
GoogleTokenResponse response = flow.newTokenRequest(code).setRedirectUri(REDIRECT_URI).execute();
GoogleCredential credential = new GoogleCredential().setFromTokenResponse(response);
//Create a new authorized API client
Drive service …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的Hadoop集群中的现有数据(JSON)迁移到Google云端存储.
我已经探索过GSUtil,它似乎是将大数据集移动到GCS的推荐选项.它似乎可以处理庞大的数据集.虽然GSUtil似乎只能将数据从本地机器移动到GCS或S3 < - > GCS,但是无法从本地Hadoop集群移动数据.
将数据从本地Hadoop集群移动到GCS的推荐方法是什么?
对于GSUtil,它可以直接将数据从本地Hadoop集群(HDFS)移动到GCS,还是首先需要在运行GSUtil的机器上复制文件然后转移到GCS?
使用Google客户端(Java API)库与GSUtil的优缺点是什么?
非常感谢,
java ×6
android ×4
google-api ×4
google-docs ×1
http-post ×1
httprequest ×1
httpresponse ×1
json ×1
maven ×1
recurrence ×1