【问题标题】:How to apply Rich Text formatting in Podio comments while adding comments through comments API如何在通过评论 API 添加评论时在 Podio 评论中应用富文本格式
【发布时间】:2017-07-21 09:42:26
【问题描述】:

我想在通过 Podio-Comments API 添加的 cmets 上应用富文本格式(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";
}

【问题讨论】:

  • 你能贴出你尝试的代码吗...
  • 它运行良好。你能添加预期的输出吗?
  • 你能分享一下结果的截图吗?并澄清预期的结果是什么?
  • 尝试将“
    ”替换为“\n”

标签: php podio


【解决方案1】:

尝试将"&lt;br /&gt;" 替换为"\n"

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

【讨论】:

    【解决方案2】:

    当我们在特殊字符之前和之后留一个空格时,格式化有效,在此评论中,开发人员必须在 * 或 \n 之前和之后添加空格,然后它必须有效。

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

    【讨论】:

      猜你喜欢
      • 2014-07-06
      • 2022-11-18
      • 1970-01-01
      • 2014-01-23
      • 1970-01-01
      • 1970-01-01
      • 2018-12-23
      • 2019-09-21
      • 1970-01-01
      相关资源
      最近更新 更多