我已将Asana任务列表集成到我公司的开发团队网站中。一直进展到今天 - 我创建的页面现在出错,响应代码为NULL(或0)。在我非常有限的经历中,这是Asana连接的问题,对吗?这是我可以解决的问题,还是Asana API目前正在下降(考虑到这一点一直持续到今天)?
我们使用的是API密钥,而不是OAuth,因为每个有权访问此任务列表的人都在同一个工作区中。
编辑: 我有2个api键,我正在使用 - 1个用于生产,1个用于开发。当我移交一个分支让我的老板合并时,我将它们切换出来。
测试API密钥工作得很好。 生产API密钥不起作用 - 在尝试撤回任务时始终为响应代码为null。
我是API开发的新手,我不知道如何使用curl来进行这些调用。我正在使用这里找到的库:
https://github.com/ajimix/asana-api-php-class/blob/master/asana.php
更具体地说,这是我的代码:
/*
* We are only interested in the JVZoo workspace
* Unless we are testing, in which we will use Faith In Motion workspace
*/
$JVZ_workspace_id = 18868754507673;
$FIM_workspace_id = 47486153348950;
/*
* Which one are we using right now?
*/
$workspace = $FIM_workspace_id;
/*
* Now lets do the same thing with Projects
* There should only be one project - JVZoo.com
* Unless we are testing - More JVZoo Testing
*
* We do need to dynamically show the project name
* This will help on confusion if we are accidently in the
* wrong project
*
* Then start building an array with these pieces
*/
$JVZ_project = array();
$JVZ_project['id'] = 53244927972665;
$JVZ_project['name'] = "JVZoo.com";
$FIM_project = array();
$FIM_project['id'] = 54787074465868;
$FIM_project['name'] = "More JVZoo Testing";
/*
* Which one are we using?
*/
$project = $FIM_project;
/*
* In order to help reduce load time even more,
* we are not going to return the project name
*
* This way we do not need to ask Asana for the project information
* This does change the layout of the view, however
*
* And finally grab all tasks for each project
* Connection check
*
* Return all tasks from this workspace and hand-filter
* to show both assigned and followed tasks
*/
$tasksJson = $asana->getProjectTasks($project['id']);
if ($asana->responseCode != '200' || is_null($tasksJson))
{
$this->session->set_flashdata('error', 'Error while trying to get tasks from Asana, response code: ' . $asana->responseCode);
redirect_and_continue_processing('/dashboard');
return;
}
FIM是我的测试环境。
JVZ是我的生产环境。
/**
* Returns all unarchived tasks of a given project
*
* @param string $projectId
* @param array $opt Array of options to pass
* (@see https://asana.com/developers/documentation/getting-started/input-output-options)
*
* @return string JSON or null
*/
public function getProjectTasks($projectId, array $opts = array())
{
$options = http_build_query($opts);
return $this->askAsana($this->taskUrl . '?project=' . $projectId . '&' . $options);
}
我对传入上面返回的行的参数执行了PR。在我的FIM环境中,我得到了这个:
https://app.asana.com/api/1.0/tasks?project=54787074465868&
对于我的生产环境:
https://app.asana.com/api/1.0/tasks?project=53244927972665&