I'm trying to simply add a todo to a todolist. I have a pretty basic function here, which I know is authenticating, and it does give me permission denied errors if I have my wrong password. When I run it with all the correct info, it returns an empty string, rather than what it describes here under Create Todo and doesn't add the task.
I'm able to do GET operations as I would expect, but POST doesn't seem to have any effect
Is there something wrong with this, or another way to get more detailed info about what's working?
$username = [REDACTED];
$password = [REDACTED];
$userid = [REDACTED];
$projectid = [REDACTED];
$todolistid = [REDACTED];
$todo = "make basecamp integration work!";
$due = date('Y-m-d' , strtotime('+3 weeks'));
$url = "https://basecamp.com/".$userid."/api/v1/projects/".$projectid."/todolists/".$todolistid."/todos.json";
$data = '{
"content": "'.$todo.'",
"due_at": "'.$due.'",
"assignee": {
"id": '.$userid.',
"type": "Person"
}
}';
$cheaders = array(
'User-Agent: '.$username,
'Content-Type: application/json; charset=utf-8'
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, $username.":".$password);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_VERBOSE, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER,$cheaders);
if ($data){
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
var_dump( curl_exec($curl) );