Longman\TelegramBot\Request::getInput PHP Method

getInput() public static method

Set input from custom input or stdin and return it
public static getInput ( ) : string
return string
    public static function getInput()
    {
        // First check if a custom input has been set, else get the PHP input.
        if (!($input = self::$telegram->getCustomInput())) {
            $input = file_get_contents('php://input');
        }
        // Make sure we have a string to work with.
        if (is_string($input)) {
            self::$input = $input;
        } else {
            throw new TelegramException('Input must be a string!');
        }
        TelegramLog::update(self::$input);
        return self::$input;
    }

Usage Example

 /**
  * Handle bot request from webhook
  *
  * @return bool
  */
 public function handle()
 {
     $this->input = Request::getInput();
     if (empty($this->input)) {
         throw new TelegramException('Input is empty!');
     }
     $post = json_decode($this->input, true);
     if (empty($post)) {
         throw new TelegramException('Invalid JSON!');
     }
     return $this->processUpdate(new Update($post, $this->bot_name))->isOk();
 }
All Usage Examples Of Longman\TelegramBot\Request::getInput