是否有以非 OOP 方式访问 Google API 的参考资料?

Is there a reference for accessing the Google APIs in a non-OOP way?

我们正在尝试使用 Google API 在 Google 驱动器上创建文件夹和文档,并提供 link 来访问它们。这是一个相对简单的要求。但是,我找到的所有参考资料都显示了各种似乎使用辅助库的面向对象编程语言的代码示例。我们正在使用 ColdFusion,需要通过直接 HTTP 调用 (CFHTTP) 访问 API,对此我找不到合适的文档。

是否有任何地方的文档,从 Google 或其他地方,显示每个调用所需的 URLs 和 URL 变量?对于 oAuth2.0 和 Google 驱动器,我们都需要这些。

在这里 @ Google Drive API Explorer 您可以找到所有可用的 API。单击任何 API,您将获得所有带有描述的变量(必需和可选)。然后提出请求,他们会向您显示请求的 URL 和 json 响应。

也可以看看 this site

希望对您有所帮助。

无论如何,我都会推荐使用 Java 客户端库,主要是基于 Google 的推荐:

Although your application can complete these tasks by directly interacting with the OAuth 2.0 system using HTTP, the mechanics of server-to-server authentication interactions require applications to create and cryptographically sign JSON Web Tokens (JWTs), and it's easy to make serious errors that can have a severe impact on the security of your application.

For this reason, we strongly encourage you to use libraries, such as the Google APIs client libraries, that abstract the cryptography away from your application code.

(阅读更多 Here

我们刚刚经历了一个类似的过程来访问 Google 云存储 APIs。

如果您决定走那条路,则必须翻译 Java 代码示例以使其对 ColdFusion 友好。下面是一个向云存储发出简单请求的示例 API(获取有关我们的一个存储桶的信息):

httpTransport = createObject("java", "com.google.api.client.http.javanet.NetHttpTransport").init();
jsonFactory = createObject("java","com.google.api.client.json.jackson2.JacksonFactory").init();
credentialBuilder =
createObject("java", "com.google.api.client.googleapis.auth.oauth2.GoogleCredential$Builder");

credentialBuilder.setTransport(httpTransport);
credentialBuilder.setJsonFactory(jsonFactory);
credentialBuilder.setServiceAccountId("SERVICE_ACCOUNT_EMAIL_ADDRESS");
p12File =createObject("java", "java.io.File").init(expandPath("PATH_TO_P12_FILE"));
credentialBuilder.setServiceAccountPrivateKeyFromP12File(p12File);
StorageScopes = createObject("java", "com.google.api.services.storage.StorageScopes");

// Alternative StorageScopes: DEVSTORAGE_READ_ONLY, DEVSTORAGE_READ_WRITE
credentialBuilder.setServiceAccountScopes([StorageScopes.DEVSTORAGE_FULL_CONTROL]);
credential = credentialBuilder.build();

httpRequestInitializer = createObject("java", "com.google.api.client.http.HttpRequestInitializer");

dataStoreFactory = createObject("java", "com.google.api.client.util.store.FileDataStoreFactory").init(DATA_STORE_DIR);

storage = createObject("java", "com.google.api.services.storage.Storage$Builder").init(httpTransport, jsonFactory, credential);
storage.setApplicationName(APP_NAME);
storage = storage.build();
getBucket = storage.buckets().get(BUCKET_NAME);
getBucket.setProjection("full");
bucket = getBucket.execute();

我只是从一些评论中提取这个。

Google(搜索词:“google drive rest api") turns up an old version of the docs: "Drive REST API Reference (v1)". As per @abraham's guidance, the current version is actually this: "Drive REST API Reference (v2)”。