0
我使用的体位API PHP类来创建任务时,在这里举行:https://github.com/ajimix/asana-api-php-class快速响应码400尝试使用API
,我使用他们的几乎确切的示例代码:
<?php
// See class comments and Asana API for full info
$asana = new Asana(array('apiKey' => 'xxxxxxxxxxxxxxxxxxxxxxxx')); // Your API Key, you can get it in Asana
$workspaceId = 'XXXXXXXXXXXXXXXXXXX'; // The workspace where we want to create our task
$projectId = 'XXXXXXXXXXXXXXXXXXX'; // The project where we want to save our task
// First we create the task
$result = $asana->createTask(array(
'workspace' => $workspaceId, // Workspace ID
'name' => 'Hello World!', // Name of task
'assignee' => '[email protected]', // Assign task to...
'followers' => array('XXXXX', 'XXXXXXXX') // We add some followers to the task... (this time by ID), this is totally optional
));
// As Asana API documentation says, when a task is created, 201 response code is sent back so...
if ($asana->responseCode != '201' || is_null($result)) {
echo 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
return;
}
$resultJson = json_decode($result);
$taskId = $resultJson->data->id; // Here we have the id of the task that have been created
// Now we do another request to add the task to a project
$result = $asana->addProjectToTask($taskId, $projectId);
if ($asana->responseCode != '200') {
echo 'Error while assigning project to task: ' . $asana->responseCode;
}
变化我做这个原代码:
- 我从我的体位法的API密钥,所以我假设它应该是没有错,并把它的
apiKey
数组索引 0123内
- 我实际上并不知道工作区ID是什么,但我项目的URL格式为
https://app.asana.com/{integer}/{integer}/{integer}
,所以我使用第一个整数作为$workspaceId
,第二个整数(与第三个整数相同)作为$projectId
。我使用第二个整数为$projectId
都和$workspaceId
用同样的结局 - 我把我自己的体位电子邮件
assignee
数组索引下的createTask()
通话 - 我从
createTask()
呼叫 删除
followers
阵列项目还试图
只有这些更改,然后运行此代码,我得到Error while trying to connect to Asana, response code: 400
。在Asana页面上没有更多错误代码解释或FAQ。可能是什么问题呢?