title: Echo avatars of project members Basecamp (PHP)
body: <p>I'm working on a Basecamp widget which will have to show important information about the projects we are currently working on. Since I could not find any relevant and detailed documentation on this matter I would like to ask the community for help.</p>
  
  <p><strong>My Situation</strong></p>
  
  <p>I'm currently already echo-ing my projects, this data contains:</p>
  
  <ul>
  <li>Project Name</li>
  <li>Description</li>
  <li>Project ID</li>
  </ul>
  
  <p>And for my To-Do Items I echo the following data:</p>
  
  <ul>
  <li>Remaining To-Do Items</li>
  <li>Completed To-Do Items</li>
  <li>Total To-Do Items</li>
  <li>Progression in percentages</li>
  </ul>
  
  <p><strong>My goal</strong></p>
  
  <p>I'd like to show the avatars of all the people working on each individual project. Since this kind of programming is fairly new to me I'd appreciate some guidance on this matter.
  Since Basecamp is becoming more popular I think more people could be interested in this information. I have consulted the API for Basecamp and written a small part to attempt the echo-ing of the project members but in vain.</p>
  
  <p>I thank you for your help in advance.</p>
  
  <p>Cheers,</p>
  
  <p>J.I.N.</p>
  
  <p>(Post scriptum: This is the complete source I have until now, some value's are deliberately altered to cloak data like credentials etc. Sorry for the long post, I tried to keep it as brief as possible)</p>
  
  <p><strong>Authentication &amp; Retrieving Project Data</strong></p>
  
  <pre><code>$appName = 'MyAppName';
  $appContact = 'MyAddress';
  
  $basecampAccountId = 'MyAccountID';
  $basecampUsername = 'MyBaseCampUsername';
  $basecampPassword = 'MyPassword';
  $baseUrl = "https://basecamp.com/************/api/v1";
  
  $url= $baseUrl.'/projects.json';
  $credentials = "$basecampUsername:$basecampPassword";
  $helloHeader = "User-Agent: $appName ($appContact)";
  
  $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_USERPWD, $credentials);
      curl_setopt($ch, CURLOPT_HEADER, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);     //optional
      curl_setopt($ch, CURLOPT_MAXREDIRS, 3);             //optional
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);     //optional
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);        //optional
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);       //optional
      curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  
      curl_setopt($ch, CURLOPT_HTTPGET, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array($helloHeader));
  
      $response = curl_exec($ch);
      $errno = curl_errno($ch);
      $error = curl_error($ch);
      curl_close($ch);
  </code></pre>
  
  <p><strong>Retrieving To-Do Lists</strong></p>
  
  <pre><code>$json = $response;
  $data = json_decode($json);
  
  /*echo "&lt;br/&gt;&lt;br/&gt;";*/
  
  foreach($data as $key)
  {   
      echo "&lt;ul&gt;";
      echo "&lt;li&gt;".$key-&gt;name."&lt;/li&gt;";
      echo "&lt;li&gt;".$key-&gt;id."&lt;/li&gt;";
      echo "&lt;li&gt;".$key-&gt;description."&lt;/li&gt;";
  
      $url= $baseUrl.'/projects/'.$key-&gt;id.'/todolists.json';
  $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_USERPWD, $credentials);
      // curl_setopt($ch, CURLOPT_HEADER, true);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);     //optional
      curl_setopt($ch, CURLOPT_MAXREDIRS, 3);             //optional
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);     //optional
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);        //optional
      curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);       //optional
      curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  
      curl_setopt($ch, CURLOPT_HTTPGET, true);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array($helloHeader));
  
      $response = curl_exec($ch);
      $errno = curl_errno($ch);
      $error = curl_error($ch);
      curl_close($ch);
  
      // print_r($response);
  
      $json = $response;
      $data = json_decode($json);
  
      $todo_remain = $data[0]-&gt;remaining_count;
      $todo_completed = $data[0]-&gt;completed_count;
      $todo_total = $todo_remain + $todo_completed;
  
      echo "&lt;BR&gt;";
      echo "&lt;BR&gt;";
      echo "Remaining To-Do Items:";
      echo "&lt;BR&gt;";
      echo $todo_remain;
      echo "&lt;BR&gt;";
      echo "Completed To-Do Items:";
      echo "&lt;BR&gt;";
      echo $todo_completed;
      echo "&lt;BR&gt;";
      echo "Total To-Do Items:";
      echo "&lt;BR&gt;";
      echo $todo_total;
      echo "&lt;BR&gt;";
      echo "Remaining percentage is: &lt;BR&gt;";
      echo round(($todo_remain/$todo_total)*100);
      echo "%";
      echo "&lt;BR&gt;";
      echo "Completed percentage is: &lt;BR&gt;";
      echo round(($todo_completed/$todo_total)*100);
      echo "%";
  
  
      echo "&lt;/ul&gt;";
  </code></pre>