问题
谁能给我指出一个分步示例,该示例解释了如何开始使用 Google Contacts API 并展示了一个完整的工作演示?
最好使用 Java,但也可以使用 C#、Python 或 Ruby。
目标
我想做的就是
- 加载现有联系人,
- 将其添加到一个组中
- 保存联系人。
问题
我几乎在每个层面都失败了。
- 无法进行身份验证
- 找不到包含我在 Internet 上找到的代码片段中使用的类的库
- 无法对现有联系人执行 CRUD 操作
示例
这是我正在寻找的一些伪代码。
import com.google.contacts.*
public class UpdateContactDemo {
public static void main(String args[]) {
GoogleContactsApi g = new GoogleContactsApi("username", "password");
Contact c = g.get("Bob");
c.addGroup("Friends");
g.save(c);
}
}
我已经做了什么
好吧,我用谷歌搜索了教程、API 示例和我能想到的所有其他内容,但都失败了。我找到了一堆这样的资源:
但不包含面向初学者的端到端示例。
最佳答案
我的 C# 方法是这样的:
http://nanovazquez.com/2013/01/18/working-with-google-calendar-on-dotnet/
代码可以在github上找到:here
<?xml version="1.0" encoding="utf-8"?>
<configuration>
...
<appSettings>
...
<!-- GoogleAPI credentials -->
<add key="ClientId" value="{CLIENT-ID}" />
<add key="ClientSecret" value="{CLIENT-SECRETD}" />
<!-- Update the port of the Redirect URI (don't forget to set this value also in the Google API Console) -->
<add key="RedirectUri" value="http://localhost:{PORT}/Account/GoogleAuthorization" />
</appSettings>
<system.web>
...
</configuration>
</xml>
您可以删除现有的 Google Calendar API 并添加 Google Contacts API。
试一试。
这有 Oauth 实现并且可以工作,但是 code.google.com 中的代码示例没有。
是迄今为止我发现的最好的。
关于c# - 是否有使用 Java、C#、Python 或 Ruby 编写的 Google Contacts API 的 Hello World 示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12866172/