Brendan Murty

Querying the Basecamp 2 API

5 Nov 2012

After using Basecamp 2 for some time on my Windows Phone, I decided to build a third-party web based mobile client to improve the system for mobile devices. This became UpcomingTasks.

One of the most basic requirements of the web client was that it needed to query the Basecamp API and return the results for display. Here’s my bc_results PHP function that got the job done:

// bc_results
// Purpose: Query the Basecamp API and return the result as an array
// Notes: More information about the Basecamp API can be found at
// Example: <?php print_r(bc_results('/people/me.json','99999999','dhjfksdhfjksdhfij32')); ?>
function bc_results($api_url,$bc_account_id,$bc_user_token){
			CURLOPT_URL => $api_url,
			CURLOPT_HTTPHEADER => array('Content-type: application/json','Authorization: Bearer '.$bc_user_token),
			CURLOPT_USERAGENT => 'SampleAppName ('
		return json_decode(curl_exec($ch),'true');