Basecamp API PHP Class Documentation
Note: Better documentation will come - I just wanted to get something up quickly.
Initialize The Class
$bc = new Basecamp('https://your.basecamp.url','username','password');
Post Messages
$bc->set_project_id(PROJECT-ID); // required $bc->set_category_id(CATEGORY-ID); // required $bc->set_is_private(1); // optional - (0) or don't set it for non-private $bc->post_message('MESSAGE TITLE','MESSAGE BODY');
Update Messages
$bc->set_resource_id(RESOURCE-ID); // All of these parameters are optional - updates what you provide. $params = array("title" => "TITLE", "body" => "BODY", "category_id" => CAT-ID, "milestone_id" => 'MILESTONE-ID'); $bc->update_message($params);
Post Comments
// Resource ID (integer) for any message, to-do list, or milestone $bc->set_resource_id(RESOURCE-ID); // Resource Type [posts|milestones|todo_items] $bc->set_resource(RESOURCE-TYPE); $bc->post_comment('TITLE','MESSAGE');
Post To-Do Lists
$bc->set_project_id(PROJECT-ID); // required $bc->set_is_private(1); // optional - (0) or don't set it for non-private $bc->post_todo_list('TITLE','DESCRIPTION'); // Description is optional
Post To-Do Items
$bc->set_todo_list_id(LIST-ID); // required $bc->post_todo_item('ITEM-TEXT',PERSON-ID,1); // 1 is optional for notification
Post Milestones
$bc->set_project_id(PROJECT-ID); // required $bc->set_deadline('DD-MM-YYYY'); // Required // Returns the newly created Milestone's ID $id = $bc->post_milestone('TITLE',PERSON-ID, 1); // 1 is optional for notification
Attaching a File to a Message or Comment
// attach_file requires (ABSOLUTE-PATH, TITLE, MIME-TYPE) // http://www.webmaster-toolkit.com/mime-types.shtml $bc->attach_file($_SERVER['DOCUMENT_ROOT'].'/images/test.jpg','Test Image','image/jpeg'); $bc->set_project_id(15598); $bc->set_is_private(1); // Optional $bc->post_message('TITLE','BODY'); // Remove file attachments from PHP Class $bc->clear_attachment_xml();
Get Categories
$bc->set_project_id(PROJECT-ID); // Required // Defaults to "Post" - you can pass it "attachment" if you wish. // Returns an array: $categories[0]['name'] and $categories[0]['id'] $categories = $bc->get_categories();
Get Default Category
$bc->set_project_id(PROJECT-ID); // Required // Defaults to "Post" - you can pass it "attachment" if you wish. // Returns the ID (Typical Basecamp - whichever one is alphabetically first) $id = $bc->get_default_category_id();
Other Public Methods
$bc->set_basecamp_url($url); $bc->set_username($user); $bc->set_password($pass); $bc->set_resource_id($id); $bc->set_resource($resource); $bc->set_category_id($id); $bc->set_project_id($id); $bc->set_todo_list_id($id); $bc->set_person_id($id); $bc->set_deadline($deadline); $bc->set_is_private($bool); $bc->get_basecamp_url(); $bc->get_username(); $bc->get_password(); $bc->get_request_url(); $bc->get_resource(); $bc->get_resource_id(); $bc->get_category_id(); $bc->get_project_id(); $bc->get_todo_list_id(); $bc->get_person_id(); $bc->get_deadline(); $bc->get_post_resource_id(); $bc->get_upload_id(); $bc->get_attachment_xml(); $bc->get_is_private(); $bc->clear_attachment_xml();