/** * Return curl resource * * @param string $url * @param array|null $headers * @return resource */ private function &getHandle($url, $headers) { $http = curl_init(); curl_setopt($http, CURLOPT_USERAGENT, Client::getUserAgent()); curl_setopt($http, CURLOPT_RETURNTRANSFER, true); curl_setopt($http, CURLINFO_HEADER_OUT, true); curl_setopt($http, CURLOPT_URL, $url); if (is_array($headers) && count($headers)) { curl_setopt($http, CURLOPT_HTTPHEADER, $headers); } return $http; }
<?php require 'vendor/autoload.php'; use ActiveCollab\SDK\Client as API; API::setUrl('https://myaccount.manageprojects.com'); API::setKey('MY-API-TOKEN'); print '<pre>'; print "API info:\n\n"; var_dump(API::info()); print "Defined project templates:\n\n"; var_dump(API::get('projects/templates')); print "Task creation example:\n\n"; var_dump(API::post('projects/65/tasks', ['task[name]' => 'This is a task name', 'task[assignee_id]' => 48, 'task[other_assignees]' => [3, 1]], ['/Library/WebServer/Documents/BZHI6GtCQAEEMz-.jpg-large.jpeg'])); print '</pre>';