Fix bugs in SendVideo, SendImage

This commit is contained in:
Daniele Callari 2020-04-03 18:41:16 +02:00
parent 11e28c717d
commit 81acae2437

View File

@ -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,7 +264,7 @@ 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,