如何通过注释API添加注释时在Podio注释中应用RTF格式

时间:2017-07-21 09:42:26

标签: php podio

我想对通过Podio-Comments API添加的评论应用富文本格式(Markdown语言)。我已经添加了,但它对我没用。 我怎么能这样做?

<?php

error_reporting(0);

require_once 'config.php';
include 'podio_api.php';
echo "START";

// Podio authentication 
podioAuthentication();
if (Podio::is_authenticated()) {
    $ref_type = "item";
    $ref_id = 603929471;
    $response = PodioComment::get_for($ref_type, $ref_id);

    $comments = '';
    foreach ($response as $object) {
        $comment = $object->value;
        $date = $object->created_on;
        $created_on = $date->format('Y-m-d H:i:s');

        // Add comment
        $comments .= "*[Created_On]* $created_on   <br /> **[Comment]** $comment   <br />";
    }
    $ref_id = 649113086;
    $attributes = ['alert_invite' => FALSE,
        'hook' => FALSE,
        'silent' => FALSE,
        'value' => $comments
    ];
    $comment_add = PodioComment::create($ref_type, $ref_id, $attributes);
    var_dump($comment_add);
    echo "DONE";
} else {
    echo "authentication error";
}

2 个答案:

答案 0 :(得分:1)

尝试用"<br />"

替换"\n"
$comments .= "*[Created_On]* $created_on   \n **[Comment]** $comment \n";

答案 1 :(得分:0)

当我们在特殊的charector之前和之后留下空格时,格式化工作,在这个评论中,开发人员必须在&amp;之前添加空格。在*或\ n后,它必须工作。

$comments .= " **[Created_On]** $created_on \n **[Comment]** $comment \n ";