PHP code example of madmagestelegram / types

1. Go to this page and download the library: Download madmagestelegram/types library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

madmagestelegram / types example snippets


$message = new Message();
$message->setText('Hello world!');

echo $message->getText(); // "Hello world!"
// as assoc array
print_r($message->_getData());// ['text' => 'Hello world!']

$message = ( new Message() )
        ->setMessageId(1)
        ->setDate(time())
        ->setChat(( new Chat() )->setId(1)->setType('channel'))
        ->setText('Hello world!')
        ->setAudio(
            ( new Audio() )
                ->setFileId("1")
                ->setDuration(60)
                ->setTitle('Some title')
                ->setThumb(( new PhotoSize() )
                    ->setFileId("1")
                    ->setHeight(100)
                    ->setWidth(100)
                )
        )->setLocation(
            ( new Location() )
                ->setLatitude(60.60)
                ->setLongitude(60.60)
        );

    print_r($message->_getData());
    
/*
    
Array
(
    [message_id] => 1
    [date] => 1570945477
    [chat] => Array
        (
            [id] => 1
            [type] => channel
        )

    [text] => Hello world!
    [audio] => Array
        (
            [file_id] => 1
            [duration] => 60
            [title] => Some title
            [thumb] => Array
                (
                    [file_id] => 1
                    [width] => 100
                    [height] => 100
                )

        )

    [location] => Array
        (
            [longitude] => 60.6
            [latitude] => 60.6
        )

)
*/