Longman\TelegramBot\Request::initialize PHP Method

initialize() public static method

Initialize
public static initialize ( Telegram $telegram )
$telegram Telegram
    public static function initialize(Telegram $telegram)
    {
        if (is_object($telegram)) {
            self::$telegram = $telegram;
            self::$client = new Client(['base_uri' => self::$api_base_uri]);
        } else {
            throw new TelegramException('Telegram pointer is empty!');
        }
    }

Usage Example

 /**
  * Constructor
  *
  * @param string $api_key
  * @param string $bot_name
  */
 public function __construct($api_key, $bot_name)
 {
     if (empty($api_key)) {
         throw new TelegramException('API KEY not defined!');
     }
     if (empty($bot_name)) {
         throw new TelegramException('Bot Username not defined!');
     }
     $this->api_key = $api_key;
     $this->bot_name = $bot_name;
     //Set default download and upload path
     $this->setDownloadPath(BASE_PATH . '/../Download');
     $this->setUploadPath(BASE_PATH . '/../Upload');
     //Add default system commands path
     $this->addCommandsPath(BASE_COMMANDS_PATH . '/SystemCommands');
     Request::initialize($this);
 }
All Usage Examples Of Longman\TelegramBot\Request::initialize