提取数据到Active Collab任务中,带有标签的HTML – PHP。

huangapple go评论81阅读模式
英文:

Extract Data to Active Collab Tasks with Tags HTML - PHP

问题

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?

我的代码尝试从Active Collab的API中获取数据,但在任务的正文中存在HTML标签,导致代码混乱,有人知道我可以做什么吗?

My code to push API:

我的用于调用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:

这个返回:

英文:

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 = &#39;token&#39;;
        curl_setopt_array($ch, [
            CURLOPT_URL =&gt; &#39;https://collab.cadastra.com.br/api/v1/projects/projectnumber/tasks/&#39;,

            CURLOPT_HTTPHEADER =&gt; [
                &#39;X-Angie-AuthApiToken: &#39; . $token,
                &#39;Content-Type: application/json&#39;,
                &#39;x-li-format: json&#39;
            ],
            CURLOPT_RETURNTRANSFER =&gt; true,
            CURLOPT_TIMEOUT =&gt; 30,
            CURLOPT_CUSTOMREQUEST =&gt; &quot;GET&quot;,
            CURLOPT_PROTOCOLS =&gt; CURLPROTO_HTTPS
        ]);

        $result = curl_exec($ch);
        // $tasks = json_decode($result, true);
        // for ($i = 0; $i &lt; count($tasks); $i++) {
        // if ($tasks[$i][&quot;task_list_id&quot;] == 55979) {
        //         $tasks_name[$i] = $tasks[$i][&quot;name&quot;];
        //     }
        // }
        
        print_r(filter_var($result, FILTER_SANITIZE_MAGIC_QUOTES));
        curl_close($ch);
        // return $resultado;
    }

    listTasks();
} catch (Error $e) {
    print_r($e-&gt;getMessage());
}
// print_r($_POST[&#39;email&#39;]));

This return:

提取数据到Active Collab任务中,带有标签的HTML – PHP。

答案1

得分: 0

你可以使用其中一个PHP函数来清除视图:

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

要查看任务,请使用其他方法,否则您必须查看请求的源代码,因为浏览器正在呈现HTML。如果您对此有任何错误,可以使用该函数来处理任务正文。

希望对您有所帮助。 提取数据到Active Collab任务中,带有标签的HTML – PHP。

英文:

you can use one of PHP function for clean view:

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. 提取数据到Active Collab任务中,带有标签的HTML – PHP。

huangapple
  • 本文由 发表于 2020年1月3日 22:31:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59580337.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定