Closed muhkuh2005 closed 8 years ago
Please show the code that actually sends the image.
Have you triple checked that the URL to the image REALLY exists?
$telegram = new Api($token); $response = $telegram->sendPhoto([ 'chat_id' => $chat_id, 'photo' => $img, 'caption' => $txt ]);
$img is a randomly chosen imagefile from a shimmie2 imageboard. $img results to be similiar to this one: "/var/www/clients/client1/web3/private/thumbs/f4/f42d2b27062054c2aa7b3a757230119e" Its an absolute path to an imagefile. I build in an existance check via PHPs function is_file() They are saved without fileendings though that doesnt seem to be a problem. I tried running the images through Imagemagick first, resizing filesize and imageresolution. But that only helps with 'some' of the images.
All the Images are static ones, no animated GIFs or similiar. The problem occurs with different Filetypes (JPEG, PNG, GIF)
The file extension does matter when working with Telegram Bot API.
Without the file extension (.jpg
, .png
), it doesn't work. Sometime ago, someone (I don't remember now) had a similar issue and the testing showed the file extension is required for it to work. So you gotta test it.
Let me know if that works.
Tried runnng 'every' image through imagemagick now. Doesn't succeed either. Heres my debug output:
root@applefritter /var/www/clients/client1/web3/private/test # php telegram.php Starting method selectid Image has passed double-post check. selectID wordked, ID: 1176 Starting method selectfilename Starting method hasArtist filename is: 5716a94ce1495bfdbdff03c2255d2060 Starting method checkSource Thumbnail folder exists generate Thumbnail Thumbnail has been created. Actual filepath: /var/www/clients/client1/web3/private/thumbs/57/5716a94ce1495bfdbdff03c2255d2060.telegram.jpg Send to Telegram
Some raw fileinfo:
/var/www/clients/client1/web1/web/img/images/9f/9fa9d3455b7bd2817dd0a74b61dfb7d0: JPEG image data, JFIF standard 1.02, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 2181x2718, frames 3
And the by imagemagick created thumbnail:
/var/www/clients/client1/web3/private/thumbs/9f/9fa9d3455b7bd2817dd0a74b61dfb7d0.telegram.jpg: JPEG image data, JFIF standard 1.01, resolution (DPI), density 72x72, segment length 16, baseline, precision 8, 822x1024, frames 3
How large is the file? Can you increase the timeout and test?
Could you post/link to one of the problem images so I can download and test?
Also, have you tried with just a plain old non-generated image. Like for example this:
(http://www.wkhscounselors.com/images/Pictures/ArticlePics/CollegeCareer/-testing.jpg)
Just tested that image with no issues.
Sorry for the slow reply. The Filesize varies but is topped at 3MB.
I tried it out with your test-image and it worked fine when it came as the original file. Though I honestly cannot make out the difference beside the original one and the one that, as far as i know, is renamed file. (Which can be found here: https://img.sweetappleacr.es/_images/126a1755aec40030d1118ddbb667b7cf )
The files are loaded directly from the disc via absolute pathes.
Edit: Something that bugs my mind is, that some of the generated images seem to work just fine...
So I just tested your image and it works fine without any issues.
Just to make sure, I also went ahead and tested with this image, which is about 6.7 MB in size. Even that worked fine. I tested multiple such big sized HQ images without any issues and with default settings.
So here are a few things you need to analyze and try:
setTimeout($seconds)
method. Example: $telegram->setTimeout(60);
this will wait for 60 seconds before disconnecting, increase more if required. You can also set it to 0
to wait indefinitely.For now, I'm closing this ticket since there is no issue from the SDK end (Tested multiple times as already mentioned).
Feel free to open another ticket, though.
Hey there, I came up with the following Exception:
I tried to use this bot SDK to post an image into a channel. The bot is administrator of the channel and pure text messages can be send without problems. Sending an image though, ends up with an timeout.