我正在开发一个Basecamp小部件,它必须显示我们当前正在处理的项目的重要信息。由于我无法找到有关此事的任何相关详细文件,我想请求社群寻求帮助。
我的情况
我目前已经回应了我的项目,这些数据包含:
对于我的待办事项,我回应以下数据:
我的目标
我想展示所有参与每个项目的人的头像。由于这种编程对我来说相当新,我会对这个问题有一些指导。 由于Basecamp越来越受欢迎,我想更多的人可能会对这些信息感兴趣。我已经咨询了Basecamp的API,并写了一小部分来尝试项目成员的回应,但是徒劳无功。
我提前感谢你的帮助。
干杯,
J.I.N。
(后期脚本:这是我到目前为止的完整来源,有些价值被故意改为隐藏数据,如凭证等。对于长篇文章,我试图尽量保持简短)
身份验证&检索项目数据
$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);
检索待办事项列表
$json = $response;
$data = json_decode($json);
/*echo "<br/><br/>";*/
foreach($data as $key)
{
echo "<ul>";
echo "<li>".$key->name."</li>";
echo "<li>".$key->id."</li>";
echo "<li>".$key->description."</li>";
$url= $baseUrl.'/projects/'.$key->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]->remaining_count;
$todo_completed = $data[0]->completed_count;
$todo_total = $todo_remain + $todo_completed;
echo "<BR>";
echo "<BR>";
echo "Remaining To-Do Items:";
echo "<BR>";
echo $todo_remain;
echo "<BR>";
echo "Completed To-Do Items:";
echo "<BR>";
echo $todo_completed;
echo "<BR>";
echo "Total To-Do Items:";
echo "<BR>";
echo $todo_total;
echo "<BR>";
echo "Remaining percentage is: <BR>";
echo round(($todo_remain/$todo_total)*100);
echo "%";
echo "<BR>";
echo "Completed percentage is: <BR>";
echo round(($todo_completed/$todo_total)*100);
echo "%";
echo "</ul>";