我似乎在尝试使用 Asana API 时遇到了困难。我正在尝试在特定项目上发布任务。
这是我正在尝试的:
$api = 'myapikey';
$url = 'https://app.asana.com/api/1.0/tasks';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Don't print the result
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // Don't verify SSL connection
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0); // "" ""
curl_setopt($curl, CURLOPT_USERPWD, $api);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$data = array(
"data" => array(
"workspace" => "workspace id",
"name" => "Task Name",
"notes" => "notes",
"assignee" => "assignee id"
)
);
$data = json_encode($data);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$html = curl_exec($curl);
curl_close($curl);
$html = json_decode($html);
var_dump($html);
它没有用,它在Undefined Project
. 我尝试了以下变体:
$url = 'https://app.asana.com/api/1.0/projects/4649161839339/tasks';
$url = 'https://app.asana.com/api/1.0/tasks/projects/4649161839339';
任何的想法?