GithubHelp home page GithubHelp logo

Comments (8)

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024 1

I'll find in the array the max by "file_size" and take that

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

From https://core.telegram.org/bots/api#message

$data = $telegram->getData();
$caption = $data["message"]["caption"];

from telegrambotphp.

Shoyad avatar Shoyad commented on September 28, 2024

Thanks Sir!

I understood it. But when user sends photo with caption i get two or three items on array. Your function getFile allows get only thumb photo. How i can get original photo when user sends photo + caption. Thanks

Example of log reply when user send photo + caption always diffrent one time 2 items one time three items.

[{"file_id":"AgADAgADH8AxG0vxDwX4JrdhyCFaXPTPgQ0ABKob5To0gmvyUaABAAEC",
"file_size":1750,"file_path":"photo/file_29.jpg","width":90,"height":73},{"file_id":"AgADAgADH8AxG0vxDwX4JrdhyCFaXPTPgQ0ABLumVtYgbe8TUqABAAEC",
"file_size":27040,"width":320,"height":259},{"file_id":"AgADAgADH8AxG0vxDwX4JrdhyCFaXPTPgQ0ABFLSNjs09xgvUKABAAEC","file_size":57840,"width":720,"height":582}],"caption":"15/3000/\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435/\u041a\u043e\u0440\u043e\u0431\u043a\u0438/\u0440\u043e\u0437\u0430"}}]

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

The different elements in the photoSize array should be the same pic with different sizes.
You can download them all doing something like this (untested)

$photo_array = $message["photo"];
for ($i = 0; $i < count($photo_array); $i++) {
   $file_id = $photo_array[$i]["file_id"];
   $file = $telegram->getFile($file_id);
   $telegram->downloadFile($file["file_path"], "./test_download". $i . ".png");
}   

from telegrambotphp.

Shoyad avatar Shoyad commented on September 28, 2024

Thanks!

But I prefered other way beacuse i need one big photo and upload it on server

foreach($photo_array as $item=>$value) { if($value['width'] > 90) { $bigPhoto[] = $value; } }

from telegrambotphp.

Shoyad avatar Shoyad commented on September 28, 2024

How to right way for binding action for file uploading.
My action:

`$result = $telegram->getData();
if($result['message']['photo'] != 0) {

some code

}`

But i've some problems with that way. It works not correctly and exucute through time.

Thanks

from telegrambotphp.

Eleirbag89 avatar Eleirbag89 commented on September 28, 2024

check if isset($result['message']['photo']) && count($result['message']['photo']) > 0

from telegrambotphp.

Shoyad avatar Shoyad commented on September 28, 2024

Thanks it works.

from telegrambotphp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.