我试图弄清楚如何使用 Google 任务 API 添加任务。文档留下了很多要调查的东西,我看到被卡住了。这是我的代码:
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Tasks($client);
...
... get token etc...
...
// Create a task
$task = new Google_Service_Tasks_Task();
$task->setTitle("Call mum");
$task->setNotes("Inserted by app");
$task->setStatus("needsAction");
$task->setDue(new DateTime('2020-01-01T00:00:01.000Z'));
// constructor needs 4 params: service, serviceName, resourceName, resource
$res = new Google_Service_Tasks_Resource_Tasks('', '', '', '');
$res->insert($lastListID, $task);
创建新的 Google_Service_Tasks_Resource_Tasks(倒数第二行)时,我需要向构造函数提供 4 个参数:service、serviceName、resourceName、resource。我找不到任何解释最后三个参数的文档。我使用这个类是因为它有一个插入方法,我认为这是我需要的。这些例子都停留在列出任务(作品)上。我试着理解这些文档:
- https://developers.google.com/tasks/v1/reference/tasks/insert
- https://developers.google.com/resources/api-libraries/documentation/tasks/v1/php/latest/index.html
我无法理解供应商目录中的实际类。有谁知道如何驯服这个API?