如何从文本API中删除单个字符串行


How to delete individual line of string from text API?

目前我已经开发了一个LAME服务器,用于运行Sweet Board应用程序。这个过程非常简单,但有一个问题;如果用户发送了不合适的消息,我希望确保它能被快速删除。因此,我在.php文件中开发了一个删除按钮,用于处理传入消息,但一旦按下按钮;它会删除屏幕上发送的每个txt消息。如何使其只删除一条消息而不是多条消息。如有任何协助,我们将不胜感激。

注意:尚未找到解决方案。

(可以在这里找到更多信息:https://github.com/barrel/sweet-board)

代码:

    <?php
    require('twilio.php');
    include('config.php');
    $client = new Services_Twilio($sid, $token);
    $textcount=0;
    foreach ($client->account->sms_messages as $message) {
        $status= $message->status;
        if ($status=='received'){
            $time = date('c', strtotime($message->date_created));
            $body = $message->body;
            $smsid= $message->sid;  
    ?>
    <article <?php if ($textcount >= 6){ ?>class="hidden" <?php } ?>data-sid="<? 
    php echo $smsid; ?>">
        <blockquote>
          <p><em>&#8220;</em><?php echo $body; ?><em>&#8221;</em></p>
        </blockquote>
          <script src="https://code.jquery.com/jquery-1.10.2.js"></script>  
      <button>Delete</button>
     <script>
     $( "button" ).click(function() {
     $( "blockquote" ).remove();
     });
        </script>
     <abbr class="timeago" title="<?php echo $time; ?>"></abbr>
    </article>
    <?php
        $textcount++;
        }
      }
     ?>
   </style> 
   </body>
   </html>

您可以使用为块引号指定id

<blockquote id='id_<?php echo $smsid;?>"></blockquote>

<button data-blockId="id_<?php echo $smsid;?>">Delete</button>

$("button").click(function() {
    var id = $(this).data('blockId'):
    $("#"+id).remove();
});

如果没有foreach,点击按钮的javascript代码会更好。