src/Request.php
/**
     * Execute cURL call
     *
     * @param string     $action Action to execute
     * @param array|null $data   Data to attach to the execution
     *
     * @return mixed Result of the cURL call
     */
Execute cURL call
@param string     $action Action to execute
@param array|null $data   Data to attach to the execution

@return mixed Result of the cURL call
Execute cURL call @param string $action Action to execute @param array|null $data Data to attach to the execution @return mixed Result of the cURL call
public static function executeCurl($action, array $data = null)
    {
        $ch = curl_init();
        if ($ch === false) {
            throw new TelegramException('Curl failed to initialize');
        }
        $curlConfig = [
            CURLOPT_URL            => 'https://api.telegram.org/bot' . self::$telegram->getApiKey() . '/' . $action,
            CURLOPT_POST           => true,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SAFE_UPLOAD    => true,
        ];
        if (!empty($data)) {
            $curlConfig[CURLOPT_POSTFIELDS] = $data;
        }
        if (self::$telegram->getLogVerbosity() >= 3) {
            $curlConfig[CURLOPT_VERBOSE] = true;
            $verbose = fopen('php://temp', 'w+');
            curl_setopt($ch, CURLOPT_STDERR, $verbose);
        }
        curl_setopt_array($ch, $curlConfig);
        $result = curl_exec($ch);
        if (self::$telegram->getLogVerbosity() >= 3) {
            rewind($verbose);
            $verboseLog = stream_get_contents($verbose);
            self::log('Verbose curl output:' . "\n" . htmlspecialchars($verboseLog) . "\n");
        }
        if ($action == 'getUpdates' & self::$telegram->getLogVerbosity() >= 1 | self::$telegram->getLogVerbosity() >= 3
        ) {
            self::setInputRaw($result);
            self::log($result);
        }
        if ($result === false) {
            throw new TelegramException(curl_error($ch), curl_errno($ch));
        }
        if (empty($result) | is_null($result)) {
            throw new TelegramException('Empty server response');
        }
        curl_close($ch);
        return $result;
    }
public static function executeCurl ( $ action , array $ data = null ) { $ ch = curl_init ( ) ; if ( $ ch === false ) { throw new TelegramException ( 'Curl failed to initialize' ) ; } $ curlConfig = [ CURLOPT_URL => 'https://api.telegram.org/bot' . self :: $ telegram -> getApiKey ( ) . '/' . $ action , CURLOPT_POST => true , CURLOPT_RETURNTRANSFER => true , CURLOPT_SAFE_UPLOAD => true , ] ; if ( ! empty ( $ data ) ) { $ curlConfig [ CURLOPT_POSTFIELDS ] = $ data ; } if ( self :: $ telegram -> getLogVerbosity ( ) >= 3 ) { $ curlConfig [ CURLOPT_VERBOSE ] = true ; $ verbose = fopen ( 'php://temp' , 'w+' ) ; curl_setopt ( $ ch , CURLOPT_STDERR , $ verbose ) ; } curl_setopt_array ( $ ch , $ curlConfig ) ; $ result = curl_exec ( $ ch ) ; if ( self :: $ telegram -> getLogVerbosity ( ) >= 3 ) { rewind ( $ verbose ) ; $ verboseLog = stream_get_contents ( $ verbose ) ; self :: log ( 'Verbose curl output:' . " \n " . htmlspecialchars ( $ verboseLog ) . " \n " ) ; } if ( $ action == 'getUpdates' & self :: $ telegram -> getLogVerbosity ( ) >= 1 | self :: $ telegram -> getLogVerbosity ( ) >= 3 ) { self :: setInputRaw ( $ result ) ; self :: log ( $ result ) ; } if ( $ result === false ) { throw new TelegramException ( curl_error ( $ ch ) , curl_errno ( $ ch ) ) ; } if ( empty ( $ result ) | is_null ( $ result ) ) { throw new TelegramException ( 'Empty server response' ) ; } curl_close ( $ ch ) ; return $ result ; }
Execute cURL call
 @param string     $action Action to execute
 @param array|null $data   Data to attach to the execution
Execute cURL call @param string $action Action to execute @param array|null $data Data to attach to the execution
//Logging curl requests //Logging getUpdates Update //Logging curl updates