public static function sendRequest($method = 'sendMessage', $params)
    {
        $curl = curl_init(self::$api_url . self::$api_token . '/'. $method);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

        if(self::$proxy) {
            curl_setopt_array($curl, self::setProxy());
        }

        $curl_result = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);

        if ($http_code != 200) {
            if ($curl_result) {
                $curl_result = json_decode($curl_result, true);
                throw new \Exception($curl_result['description']);
            }
            throw new \Exception('an error was encountered');
        }

        return $curl_result;
    }
public static function sendRequest($method = 'sendMessage', $params)
    {
        $curl = curl_init(self::$api_url . self::$api_token . '/'. $method);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

        if(self::$proxy) {
            curl_setopt_array($curl, self::setProxy());
        }

        $curl_result = curl_exec($curl);
        $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
        curl_close($curl);

        if ($http_code != 200) {
            if ($curl_result) {
                $curl_result = json_decode($curl_result, true);
                throw new \Exception($curl_result['description']);
            }
            throw new \Exception('an error was encountered');
        }

        return $curl_result;
    }
public static function sendRequest ( $ method = 'sendMessage' , $ params ) { $ curl = curl_init ( self :: $ api_url . self :: $ api_token . '/' . $ method ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ curl , CURLOPT_POST , 1 ) ; curl_setopt ( $ curl , CURLOPT_POSTFIELDS , http_build_query ( $ params ) ) ; curl_setopt ( $ curl , CURLOPT_SSL_VERIFYPEER , false ) ; if ( self :: $ proxy ) { curl_setopt_array ( $ curl , self :: setProxy ( ) ) ; } $ curl_result = curl_exec ( $ curl ) ; $ http_code = curl_getinfo ( $ curl , CURLINFO_HTTP_CODE ) ; curl_close ( $ curl ) ; if ( $ http_code != 200 ) { if ( $ curl_result ) { $ curl_result = json_decode ( $ curl_result , true ) ; throw new \ Exception ( $ curl_result [ 'description' ] ) ; } throw new \ Exception ( 'an error was encountered' ) ; } return $ curl_result ; }
Send Request to Telegram api

@param string $method
@param $params
@return mixed
@throws \Exception
Send Request to Telegram api