我正在用wrike开发一份任务报告,我想知道是否可以让它更快。我对卷曲并不舒服,我不习惯使用它。欢迎所有帮助:)。
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$headers = array();
$headers[] = "Authorization: bearer ".$_COOKIE["wrike_token"];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
foreach($folderArray as $currentFolder){
curl_setopt($ch, CURLOPT_URL, "https://www.wrike.com/api/v3/folders/".$currentFolder->id."/tasks?completedDate={'start':'2016-10-11T00:01:00Z','end':'2016-10-11T23:59:00Z'}");
$result = curl_exec($ch);
$result = json_decode($result);
if(!empty($result->data)){
foreach($result->data as $currentTask){
echo $currentFolder->title." : ".$currentTask->title."<br>";
}
}
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
}
curl_close ($ch);`
答案 0 :(得分:0)
使用PHP request库可以让您的工作更轻松:
示例:
$headers = array('Authorization' => 'bearer '.$_COOKIE["wrike_token"]);
$options = array('completedDate'=>"{'start':'2016-10-11T00:01:00Z','end':'2016-10-11T23:59:00Z'}");
$url = 'https://www.wrike.com/api/v3/folders/'.$currentFolder->id.'/tasks';
$request = Requests::get($url, $headers, $options);
答案 1 :(得分:0)
您可以使用https://github.com/marcushat/RollingCurlX来进行并行cURL请求,并且比顺序提取更快地提取。