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。可能是什麼問題呢?