Php 使用api向asana任务添加追随者
我只是不知道为什么会失败。我有以下尝试将任务添加到Asana的方法:Php 使用api向asana任务添加追随者,php,api,task,asana,Php,Api,Task,Asana,我只是不知道为什么会失败。我有以下尝试将任务添加到Asana的方法: $arrayOfIds = array("0123456789", "9876543210"); $followers = implode('", "', $arrayOfIds); $newtask = $asana->createTask(array( "workspace" => $workspaceId, "name" => $name, "team" => $team
$arrayOfIds = array("0123456789", "9876543210");
$followers = implode('", "', $arrayOfIds);
$newtask = $asana->createTask(array(
"workspace" => $workspaceId,
"name" => $name,
"team" => $teamId,
"assignee" => $assignee,
"due_on" => $dueOn,
"completed" => $completed,
"completed_at" => $completedAt,
//"followers" => array("0123456789")
"followers" => array($followers)
));
当我手动输入用户ID时,它工作得很好,就像上面注释的代码一样,但是当我尝试使用数组时失败了。我得到以下错误:
尝试连接到Asana时出错,响应代码:400
非常感谢您的帮助。不知道$asana lib是如何实现的链接?我的猜测是数组编码不正确。如果通过url编码的post数据而不是JSON发送,则数组应以逗号分隔。当它应该是followers=1,2时,PHP可能会执行followers[]=1和followers[]=2之类的操作 尝试执行followers=>infrade、$arrayOfIds之类的操作,或者检查库的代码以查看它如何对数组进行编码。此外,包括实际的HTTP请求/响应将有助于了解发生了什么。有很多方法可以做到这一点-您的库可能包括详细/调试模式,但如果所有其他模式都失败,您可以始终使用Charles Proxy、Wireshark、eTerCap等