PHP code example of thisismzm / tdlib-php-ffi

1. Go to this page and download the library: Download thisismzm/tdlib-php-ffi 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/ */

    

thisismzm / tdlib-php-ffi example snippets


/**
* @param string|null $tdlibFilePath A file path/name to `libtdjson.so` library
*/
public function __construct(string $tdlibFilePath)

/**
 * @return int an opaque identifier of a new TDLib instance
 */
public function createClientId(): int

/**
 * @param int $clientId TDLib client id
 * @param string $request $request JSON-serialized request to TDLib.
 * 
 * @return void
 */
public function send(int $clientId, string $request): void

/**
 * @param int $timeout The maximum number of seconds allowed for this function to wait for new data
 * 
 * @return string|null incoming update or request response or may be null if the timeout expires.
 */
public function receive(int $timeout): ?string

/**
* @param string $request JSON-serialized request to TDLib.
* 
* @return string|null JSON-serialized null-terminated request response.
*/
public function execute(string $request): ?string