diff --git a/Telegram.class.php b/Telegram.class.php index cdf835c..e0171cb 100644 --- a/Telegram.class.php +++ b/Telegram.class.php @@ -10,7 +10,7 @@ class TelegramBot # # version # - const Version = '1.3'; + const Version = '1.3.2.0'; # # limit of http retry @@ -92,9 +92,11 @@ class TelegramBot # set options # curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data) ); + curl_setopt($ch, CURLOPT_POSTFIELDS, ($data) ); + //curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data) ); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:multipart/form-data"]); # # do http call with retry @@ -224,7 +226,7 @@ class TelegramBot # public function SendDocument($destination, $url) { - if( strpos('http', $url) === 0 ) + if( strpos($url, 'http') === 0 ) { return $this->_httpSend('sendDocument', array( 'chat_id' => $destination, @@ -233,7 +235,26 @@ class TelegramBot }else{ return $this->_httpSend('sendDocument', array( 'chat_id' => $destination, - 'photo' => new CURLFile($url) + 'document' => new CURLFile($url) + )); + } + } + + # + # send document + # + public function SendVideo($destination, $url) + { + if( strpos($url, 'http') === 0 ) + { + return $this->_httpSend('sendVideo', array( + 'chat_id' => $destination, + 'video' => $url + )); + }else{ + return $this->_httpSend('sendVideo', array( + 'chat_id' => $destination, + 'video' => new CURLFile($url) )); } } @@ -243,16 +264,16 @@ class TelegramBot # public function SendImage($destination, $url) { - if( strpos('http', $url) === 0 ) + if( strpos($url, 'http') === 0 ) { return $this->_httpSend('sendPhoto', array( 'chat_id' => $destination, 'photo' => $url )); }else{ - return $this->_httpSend('sendPhoto', array( - 'chat_id' => $destination, - 'photo' => new CURLFile($url) + return $this->_httpSend('sendPhoto', array( + 'chat_id' => $destination, + 'photo' => new CURLFile($url) )); } }