# task notes
$tasknotes = "Intern: " . $document->internal_party;
$tasknotes .= "\n";
$tasknotes .= "Kommentar: " . $document->comment;
$tasknotes .= "\n\n";
$tasknotes .= $filepath;
# Asana implementation
require_once dirname(__FILE__) . '/php-asana-api/asana.php';
# API key, workspace and project
$asana = new Asana(array('apiKey' => ASANA_APIKEY));
# workspace 'xxx'
$workspaceId = $document->asana_workspace_id;
# project 'xxx'
$projectId = $document->asana_project_id;
# create the task
$result = $asana->createTask(array('workspace' => $workspaceId, 'name' => $taskname, 'notes' => $tasknotes, 'assignee' => $asana_owner, 'followers' => $asana_follower));
// success is 201
if ($asana->responseCode != '201' || is_null($result)) {
$asana_message = 'Error while trying to connect to Asana, response code: ' . $asana->responseCode;
$asana_error = true;
}
if (!$asana_error) {
$resultJson = json_decode($result);
# get the task id
$taskId = $resultJson->data->id;
# add the task to the project
$result = $asana->addProjectToTask($taskId, $projectId);
if ($asana->responseCode != '200') {
$asana_message = 'Error while assigning project to task: ' . $asana->responseCode;
$asana_error = true;
}