一次多个退货声明?

I am trying to develop a chat bot.

I have a doubt regarding the functionality.

Here's a part of the code:

<?php
require_once 'bootstrap.php';
require_once CB_HOME.'/library/CommonFunctions.php';

class testBot extends AbstractCbRest{
  public function subscriptionCreated($userName){
    return "Welcome ";
  } 
  public function subscriptionDeleted($userName){
    return "Thanks  ";
  }
  public function messageReceived($from, $message){
    return "" ; // how to return multiple  here
  }

In the messageReceived function ,I am going to implement the chatbot functionality.

Whenever i get a message from the user i am going to return something.For that i will have to run some php scripts and make some api calls.The final result i will send to the user.

All this is going to take approximately 20-25 seconds.

Is there a way I can send multiple return statements? Like while the Api calls are being made i can send a message to the user and then wait for the actual result to come and then send it? I cannot think of a way because as soon i sent a message,i cannot return something until and unless user replies with something.

It sounds like you need to think about using AJAX rather than making synchronous calls while the page rendering is being processed.

You could create an array and return that :

public function messageReceived($from, $message){
  $retval = array();
  $retval[] = "message1";
  $retval[] = "message2";
  return $retval;
}

or

public function messageReceived($from, $message){
  return array("message1","message2");
}

Use an array :

public function messageReceived($from, $message){
    return array(
        'Welcome',
        'Thanks',
        'Hello',
        'Whatever'
    );
}

Or even an associative array

array(
    'msg1' => 'Welcome',
    'msg2' => 'Thanks',
    'msg3' => 'Hello',
    'msg4' => 'Whathever'
)

Then you can use a particular message with :

array['msg1']