PHP code example of chanify / sdk

1. Go to this page and download the library: Download chanify/sdk 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/ */

    

chanify / sdk example snippets


use Chanify\Client;

$chanify = new Client('chanify_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

// After each bot response — add one line:
$chanify->showAd($chatId, [
    'userId'       => $userId,
    'languageCode' => $languageCode,
    'isPremium'    => $isPremium,
]);

$chanify->showAd(int $chatId, array $userMeta = []): bool



hanify\Client;

$chanify = new Client('chanify_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');

$update = json_decode(file_get_contents('php://input'), true);
$message = $update['message'] ?? null;

if ($message) {
    $chatId   = $message['chat']['id'];
    $userId   = $message['from']['id'];
    $lang     = $message['from']['language_code'] ?? null;
    $premium  = $message['from']['is_premium'] ?? false;

    // Send your bot's response first
    // ...

    // Then show an ad
    $chanify->showAd($chatId, [
        'userId'       => $userId,
        'languageCode' => $lang,
        'isPremium'    => $premium,
    ]);
}