php - optimisation of curl request -
i'm developing task report wrike , know if it's possible make faster. i'm not confortable curl, i'm not use use it. welcome :).
$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 $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 $currenttask){ echo $currentfolder->title." : ".$currenttask->title."<br>"; } } if (curl_errno($ch)) { echo 'error:' . curl_error($ch); } } curl_close ($ch);`
use php request library make work easier:
example:
$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);
Comments
Post a Comment