Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to access messages data sent by bot ? #25

Closed
moeinrahimi opened this issue Jun 23, 2016 · 4 comments
Closed

how to access messages data sent by bot ? #25

moeinrahimi opened this issue Jun 23, 2016 · 4 comments

Comments

@moeinrahimi
Copy link

hi i want to access message_ids of my bot messages and store it in a variable, i know i can access all the data by using var_dump($telegram->sendmessage($content); but how can i filter through them and only get message_id ?

@Eleirbag89
Copy link
Owner

$message = $telegram->sendmessage($content);
$msg_id = $message["message_id"];

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

@moeinrahimi
Copy link
Author

ok i tested your code but it return nothing when i var_dump($msg_id) it is NULL,
but when i var_dump the $message it returns:

Array
(
    [ok] => 1
    [result] => Array
        (
            [message_id] => 631
            [from] => Array
                (
                    [id] => 224181375
                    [first_name] => boofeh
                    [username] => boofehbot
                )

            [chat] => Array
                (
                    [id] => 50408323
                    [first_name] => MOÆŽIN
                    [username] => imoein1
                    [type] => private
                )

            [date] => 1466844672
            [text] => اکنون س�ارش خود را ارسال کنید
        )

)

@Eleirbag89
Copy link
Owner

do
$message = $telegram->sendmessage($content);
$msg_id = $message["result"]["message_id"];

works ?

@moeinrahimi
Copy link
Author

@Eleirbag89 yes it works like a charm ! thank you very much .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants