api - Wunderlist Tasks - how do I get the tasks for a list using curl in php -


i have been searching quite bit , can't overview of tasks single list using wunderlist endpoint: https://a.wunderlist.com/api/v1/tasks

i can lists, folders , create list, folders, tasks works fine. how tasks list? tried interpret documentation found here: https://developer.wunderlist.com/documentation/endpoints/task

when method error message:

{"error":{"type":"missing_parameter","translation_key":"api_error_missing_params","message":"missing parameter.","title":["required"]}} 

however, don't want add title, since don't want create new task, want tasks of list back.

what doing wrong here?

here code far:

function docall($endpoint, $parameters = array(), $method = 'get') {     // check if curl available     if (!function_exists('curl_init')) {         print "this method requires curl (http://php.net/curl), seems extension isn't installed. ".__line__;         exit();     }     //prepare content     $parametersdata = json_encode($parameters);      // define url     $url = 'https://a.wunderlist.com/api/v1/' . $endpoint;      // init curl     $curl = curl_init();     // set options     curl_setopt($curl, curlopt_url, $url);     curl_setopt($curl, curlopt_returntransfer, true);     curl_setopt($curl, curlopt_timeout, 10);     // init headers     $headers = array();      // add header     $headers[] = 'x-access-token: xxx';     $headers[] = 'x-client-id: xxx';      // method post, used login or inserts     if ($method == 'post') {         // define post method         curl_setopt($curl, curlopt_post, 1);     // method delete     } elseif ($method == 'delete') {         curl_setopt($curl, curlopt_customrequest, 'delete');     } else {         curl_setopt($curl, curlopt_httpget, 1);     }      // parameters set     if (!empty($parameters)) {         $headers[] = 'content-type: application/json';         $headers[] = 'content-length: ' . strlen($parametersdata);         curl_setopt($curl, curlopt_postfields, $parametersdata );     }     // define headers request     if (!empty($headers)) {         // add headers         curl_setopt($curl, curlopt_httpheader, $headers);     }     // execute     $response = curl_exec($curl);     // debug on     if (true) {         echo $method." ".$url . '<br/><pre>';         print"\n--headers--\n";         print_r($headers);         print"\n--parameters--\n";         print_r($parameters);         print"\n--parametersdata--\n";         print_r($parametersdata);         print"\n--response--\n";         print_r($response);         echo '</pre><br/><br/>';     }     // http response code     $httpcode = (int) curl_getinfo($curl, curlinfo_http_code);     // close     curl_close($curl);     // response empty or false     if (empty($response)) {         //throw new exception('error: ' . $response);         print "error: ". $response." ".__line__;     }     // init result     $result = false;     // successfull response     if (($httpcode == 200) || ($httpcode == 201)) {         $result = json_decode($response, true);     }     // return     return $result; }  $listid = 123; $url = 'tasks'; $tasks = docall($url,array('list_id' => $listid), 'get'); echo $tasks; 

-- edit addendum --- have tried these variants in case wonders. give same error "bad_request"

get a.wunderlist.com/api/v1/tasks{"list_id":"141329591"} a.wunderlist.com/api/v1/tasks{"list_id":141329591} a.wunderlist.com/api/v1/tasks/{"list_id":"141329591"}  

as pointed out rotem, you're using adding $parameters array curlopt_postfields. name suggests meant http post requests only.

putting parameters query params in $url , passing null query params made example work me.

$listid = 123; $url = 'tasks?list_id=123'; $tasks = docall($url,null,'get'); echo $tasks; 

note: did use list_id have access instead of using 123


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -