Skip to content

Instantly share code, notes, and snippets.

@bvlion
Created November 30, 2018 02:41
Show Gist options
  • Save bvlion/53ac2e3c56d222182eb433e529d6d5f4 to your computer and use it in GitHub Desktop.
Save bvlion/53ac2e3c56d222182eb433e529d6d5f4 to your computer and use it in GitHub Desktop.
asanaのセクション配下にタスクをPHPで追加するサンプル
<?php
$data = array('data' => array(
'memberships' => array(array('project' => $_POST['project'], 'section' => $_POST['section'])),
'name' => $_POST['word'],
'workspace' => $_POST['workspace'],
'notes' => $_POST['note']
));
$header = array(
'Content-Type: application/json',
'Authorization: Bearer ' . $bearer
);
$options = array(
'http' => array(
'ignore_errors' => true,
'method' => 'POST',
'header' => implode("\r\n", $header),
'content' => json_encode($data)
)
);
$url = 'https://app.asana.com/api/1.0/tasks';
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$result = json_decode($result);
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment