0

我已将 Asana 任务列表集成到我公司的网站中,供我们的开发团队使用。直到今天一切都很顺利——我现在创建的页面出现错误,响应代码为 NULL(或 0)。以我非常有限的经验,这是体式连接的问题,对吗?这是我可以解决的问题,还是 Asana API 当前已关闭(考虑到这一直有效)?

我们使用的是 API 密钥,而不是 OAuth,因为有权访问此任务列表的每个人都在同一个工作区中。

编辑:我有 2 个正在使用的 api 密钥 - 1 个用于生产,1 个用于开发。当我把一个分支交给我的老板合并时,我把它们关掉了。

测试 API 密钥工作得很好。生产 API 密钥不起作用 - 尝试撤回任务时始终响应代码为空。

我是 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&
4

0 回答 0