Extract Data to Active Collab Tasks with Tags HTML - PHP

孤者浪人 提交于 2020-01-17 14:43:06

问题


I am trying to pull data from API for active collab, but in the body to the task exist tags HTML, causing a mess in the coding, anybody know what I can do?

My code to push API:

    try {
    function listTasks() {  

        $ch = curl_init();
        $token = 'token';
        curl_setopt_array($ch, [
            CURLOPT_URL => 'https://collab.cadastra.com.br/api/v1/projects/projectnumber/tasks/',

            CURLOPT_HTTPHEADER => [
                'X-Angie-AuthApiToken: ' . $token,
                'Content-Type: application/json',
                'x-li-format: json'
            ],
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_PROTOCOLS => CURLPROTO_HTTPS
        ]);

        $result = curl_exec($ch);
        // $tasks = json_decode($result, true);
        // for ($i = 0; $i < count($tasks); $i++) {
        // if ($tasks[$i]["task_list_id"] == 55979) {
        //         $tasks_name[$i] = $tasks[$i]["name"];
        //     }
        // }

        print_r(filter_var($result, FILTER_SANITIZE_MAGIC_QUOTES));
        curl_close($ch);
        // return $resultado;
    }

    listTasks();
} catch (Error $e) {
    print_r($e->getMessage());
}
// print_r($_POST['email']));

This return:


回答1:


you can use one of PHP function for clean view:

  • strip_tags (https://www.php.net/manual/en/function.strip-tags)
  • htmlentities (https://www.php.net/manual/en/function.htmlentities)

for view the tasks, otherways you must look at the source of request, cause browser is rendering html. if you will have any errors for this, you can the function use for task body.

I hope it help to you. :)



来源:https://stackoverflow.com/questions/59580337/extract-data-to-active-collab-tasks-with-tags-html-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!