Using Google Docs and Google Spreadsheet APIs for

2019-03-10 16:58发布

问题:

I am planning on using the Google Documents List, and Google Documents Spreadsheet API's for uploading a database from my app to a spreadsheet online and then editing it.

I just wanted to know if these API's would be the right approach for using Google docs as an online storage space for the data that I have collected in my app.

I was hoping that I could just get feedback from some of you who might have experience with this.

The links for both API's are listed below:

http://code.google.com/apis/documents/

http://code.google.com/apis/spreadsheets/

Thanks in advance!

回答1:

(Dec 2016-Feb 2017) Various parts of this question are now out-of-date as: 1) GData APIs (including both the Documents List and Spreadsheets APIs) are the previous generation of Google APIs. While not all GData APIs have been deprecated, all modern Google APIs do not use the Google Data protocol; 2) the Google Documents List API has been replaced (and shut down in 2015) by the Google Drive API (mobile developers have a specific Google Drive Android API), 3) Google released a new Google Sheets API v4 (not GData) in 2016, and 4) Android Studio is now the preferred IDE over Eclipse.

In order to use Google APIs, you need to get the Google APIs Client Library for Android (or for more general Java, the Google APIs Client Library for Java). Now for some examples... here's the Android quickstart code sample as well as the more general Java Quickstart code sample for the Sheets API. Can't hurt to pass along the JavaDocs reference for the Sheets API either.

If you're not "allergic" to Python, I've also made several videos with more "real-world" examples using the Sheets API (non-mobile though):

  • Migrating SQL data to a Sheet (code deep dive post)
  • Formatting text using the Sheets API (code deep dive post)
  • Generating slides from spreadsheet data (code deep dive post)

The latest API provides features not available in older releases, namely giving developers programmatic document-oriented access to a Sheet as if you were using the user interface (create frozen rows, perform cell formatting, resizing rows/columns, adding pivot tables, creating charts, etc.) However, to perform file-level access such as imports & exports, you would use the Google Drive API instead -- for mobile, there's a specific Google Drive Android API.

But based on your use-case, I don't believe you need the Drive API (nor the deprecated Documents List API) unless you need to perform file operations like searching or those I described just above. You can just use the Sheets API to "upload a database from your [Android] app to a spreadsheet online and then edit it." My one video above on "migrating SQL data to a Sheet" should give you enough pseudocode (that's what Python is, isn't it?) to write your app.

To learn more about how to use Google APIs, check out the variety of Google developer videos (series 1 and series 2) I'm producing (heads-up mostly Python or JavaScript).



回答2:

For accessing Google APIs on the android platform, the Google APIs Client Library for Java is the way to go.

It includes sample apps for the Documents and Spreadsheet APIs.



回答3:

Personally I don't like Google's api lib for java. I honestly think you are better off using scribe and jackson to deserialize the feeds. We made a hello world. It includes calls with openid and oauth to spreadsheet feeds and deserialization template. Hope it helps.

link