Fix bugs in SendVideo, SendImage
This commit is contained in:
parent
11e28c717d
commit
81acae2437
|
|
@ -10,7 +10,7 @@ class TelegramBot
|
||||||
#
|
#
|
||||||
# version
|
# version
|
||||||
#
|
#
|
||||||
const Version = '1.3';
|
const Version = '1.3.2.0';
|
||||||
|
|
||||||
#
|
#
|
||||||
# limit of http retry
|
# limit of http retry
|
||||||
|
|
@ -92,9 +92,11 @@ class TelegramBot
|
||||||
# set options
|
# set options
|
||||||
#
|
#
|
||||||
curl_setopt($ch, CURLOPT_POST, 1);
|
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_VERBOSE, 0);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type:multipart/form-data"]);
|
||||||
|
|
||||||
#
|
#
|
||||||
# do http call with retry
|
# do http call with retry
|
||||||
|
|
@ -224,7 +226,7 @@ class TelegramBot
|
||||||
#
|
#
|
||||||
public function SendDocument($destination, $url)
|
public function SendDocument($destination, $url)
|
||||||
{
|
{
|
||||||
if( strpos('http', $url) === 0 )
|
if( strpos($url, 'http') === 0 )
|
||||||
{
|
{
|
||||||
return $this->_httpSend('sendDocument', array(
|
return $this->_httpSend('sendDocument', array(
|
||||||
'chat_id' => $destination,
|
'chat_id' => $destination,
|
||||||
|
|
@ -233,7 +235,26 @@ class TelegramBot
|
||||||
}else{
|
}else{
|
||||||
return $this->_httpSend('sendDocument', array(
|
return $this->_httpSend('sendDocument', array(
|
||||||
'chat_id' => $destination,
|
'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)
|
public function SendImage($destination, $url)
|
||||||
{
|
{
|
||||||
if( strpos('http', $url) === 0 )
|
if( strpos($url, 'http') === 0 )
|
||||||
{
|
{
|
||||||
return $this->_httpSend('sendPhoto', array(
|
return $this->_httpSend('sendPhoto', array(
|
||||||
'chat_id' => $destination,
|
'chat_id' => $destination,
|
||||||
'photo' => $url
|
'photo' => $url
|
||||||
));
|
));
|
||||||
}else{
|
}else{
|
||||||
return $this->_httpSend('sendPhoto', array(
|
return $this->_httpSend('sendPhoto', array(
|
||||||
'chat_id' => $destination,
|
'chat_id' => $destination,
|
||||||
'photo' => new CURLFile($url)
|
'photo' => new CURLFile($url)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user