Skip to content

How handle media(photo, pdf) messages from chat ? #441

Answered by fabio-ivona
Nurbolaaaat asked this question in Q&A
Discussion options

You must be logged in to vote
  1. I need to handle photo and pdf from user.
  2. I should store to my local project.

as for this one: starting from a Message DTO

from a webhook

$this->message

or Telegraph::botUpdates() method:

$message = Telegraph::botUpdates()->send()->json('result.0.message');
$message = Message::fromArray($message);

you can extract photos (or documents as well)

$photo = collect($message->photos())->last();

and then, store it:

Telegraph::store($photo, Storage::path('incoming/photos'), 'new-photo.jpg');
  1. I need to send this files to other chat

for this one, your code is correct (->photo(...)->send())

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@fabio-ivona
Comment options

@Nurbolaaaat
Comment options

@Nurbolaaaat
Comment options

@fabio-ivona
Comment options

Comment options

You must be logged in to vote
1 reply
@Nurbolaaaat
Comment options

Answer selected by Nurbolaaaat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants