ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# Todoist API 使用Todoist API和VBA-Web的示例包含在项目的`examples / todoist`文件夹中。 一些细节: ## [](https://github.com/VBA-tools/VBA-Web/wiki/Todoist-API#authentication)Authentication授权 Todoist [API文档](https://developer.todoist.com/)描述了如何对Todoist API进行身份验证和请求。 根据[授权:OAuth](https://developer.todoist.com/#oauth)部分,需要以下项目:客户端ID,客户端密钥和重定向URL。这些可以在[Todoist App Management Console](https://developer.todoist.com/appconsole.html)中找到。 对于重定向网址,任何有效网址似乎都有效,因为只有查询字符串用于身份验证(例如[www.example.com](http://www.example.com/),[www.yourcompany.com](http://www.yourcompany.com/)等) 1. 转到[https://developer.todoist.com/appconsole.html](https://developer.todoist.com/appconsole.html),根据需要创建一个新应用程序,并记下客户端ID和客户端密钥 2. 为您的应用设置重定向网址(请参阅上面的注释) 3. 从[https://developer.todoist.com/#oauth](https://developer.todoist.com/#oauth)确定应用程序的范围(例如`data:read,task:add`) 4. 将`TodoistAuthenticator`添加到您的项目中并按如下方式进行设置 ~~~vbnet Dim Auth As New TodoistAuthenticator Auth.Setup _ ClientId:="Your Client Id", _ ClientSecret:="Your Client Secret" RedirectUrl:="Your Redirect Url" Auth.Scope = "data:read,task:add" Set Client.Authenticator = Auth ~~~ ## [](https://github.com/VBA-tools/VBA-Web/wiki/Todoist-API#example-request)Example Request请求范例 通过客户端的身份验证设置,您可以使用正常的请求配置。 以下是检索您拥有的项目列表以及如何设置请求的所需URL的示例:(请参阅[https://developer.todoist.com/#retrieve-data](https://developer.todoist.com)) ~~~vbnet '// 期望的请求: POST https://todoist.com/API/v6/sync '// ?token=SET Automatically from TodoistAuthenticator '// &seq_no=0 '// &seq_no_global=0 '// &resource_types=["projects"] Public Function CountProjects() As Long Dim Client As New WebClient Client.BaseUrl = "https://todoist.com/API/v6" Dim Auth As New TodoistAuthenticator Auth.Setup _ ClientId:="Your Client Id", _ ClientSecret:="Your Client Secret" RedirectUrl:="Your Redirect Url" Auth.Scope = "data:read,task:add" Set Client.Authenticator = Auth Dim Request As New WebRequest Request.Resource = "sync" Request.AddQuerystringParam "seq_no", 0 Request.AddQuerystringParam "seq_no_global", 0 Request.AddQuerystringParam "resource_types", "[""projects""]" Dim Response As WebResponse Set Response = TodoistClient.Execute(Request) If Response.StatusCode = WebStatusCode.Ok Then CountProjects = Response.Data("Projects").Count End If End Function ~~~ ### [](https://github.com/VBA-tools/VBA-Web/wiki/Todoist-API#links)链接: * [Todoist API Documentation](https://developer.todoist.com/) * [Todoist OAuth](https://developer.todoist.com/#oauth) * [Todoist App Management Console](https://developer.todoist.com/appconsole.html)