LiquidPlanner Classic Forum

Ask a Question
ANSWERED
ANSWERED
ANSWERED
ANSWERED

how to use API token to authenticate

*Posted on behalf of Daniel Holly. Original posting date 2017-03-18.* Does anyone have an example of how to authenticate with an API token? Thanks!
ANSWERED

Member Expected Finish Date API

*Posted on behalf of Lee Raybone. Original posting date 2017-03-01.* Is it possible to request or find the expected finish date for a member based on all the tasks they are assigned to, using the API?
ANSWERED

Update Task Description - task_update

*Posted on behalf of a customer. Original posting date 2017-01-12.* What is the correct URL and JSON format? Here is my code, and don't worry about the $super_user_lp, it is working. Only the task_update is not working, and has no response by thisAPI call. ``` $response_update_task_prefix = $super_user_lp->task_update($task_id, $update_data); /* $update_data['name'] = "Prefix"."Original Task Name"; $update_data['description'] = "Prefix"."Original Description"; //By the way, may I update the Note like this:? $update_data['note'] = "New Note"."Original Note"; */ ``` ``` function task_update($taskid, $data){ $encodedTask = json_encode(array('task' => $data)); $url = 'https://app.liquidplanner.com/api/workspaces/{space ID}/tasks/'.$taskid; $response = $this->lp_put($url, $encodedTask); return($response); } ``` ``` function lp_put($endpoint_url, $encodedTask){ $curl = curl_init($endpoint_url); curl_setopt($curl, CURLOPT_HEADER, false); //$conn curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERPWD, trim($this->email).":".trim($this->password)); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); curl_setopt($curl, CURLOPT_ENCODING, "gzip"); ``` ``` // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_setopt($curl, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($curl, CURLOPT_URL, $endpoint_url); // curl_setopt($curl, CURLOPT_POSTFIELDS, $encodedTask); curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($encodedTask)); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec( $curl ); $error = curl_error($curl); // curl_close($curl); ``` ``` $results = json_decode($response, true); return $results; } ```
ANSWERED
ANSWERED
ANSWERED

How to get upload file path? PHP

*Posted on behalf of Feng. Original posting date 2016-12-09.* Here is the code. And the question is how to get the correct $file_path? The file supposed to be located on the local folder. Thanks! ``` $attachment_filename = "test.jpg"; $file_path = "@$attachment_filename"; ``` OR something like this: ``` $attachment_filename= $_FILES['userfile']['name'] ; $tmp_name = $_FILES['userfile']['tmp_name']; $dest_dir = 'upLoad'; $file_path = $dest_dir.'/'.$attachment_filename; ``` ... OR .... your suggestion code ``` //---------------------------------------------- $upload_file_response = $lp->attachDocument($file_path,$attachment_filename, $task_id); ``` ``` function attachDocument($file_path,$filename, $taskid) { ``` ``` $Data = array('document[attached_file]' => $file_path, 'document[file_name]'=> $filename); ``` ``` $url = $this->serviceurl . '/tasks/' . $taskid . '/documents'; $response = $this->lp_attach_file($url, $Data); return($response); } ``` ``` function lp_attach_file($endpoint_url, $Data) { ``` ``` $curl = curl_init($endpoint_url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_USERPWD, trim($this->email).":".trim($this->password)); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data")); curl_setopt($curl, CURLOPT_ENCODING, ""); // Prevent GZIP compression of response from LP ``` ``` curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_URL, $endpoint_url); curl_setopt($curl, CURLOPT_POSTFIELDS, $Data); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // Accept any SSL certificate $response = curl_exec($curl); $error = curl_error($curl); ``` ``` $results = json_decode($response, true); ``` ``` return $results; } ```
ANSWERED