PHP Classes

File: test/addContact.php

Recommend this page to a friend!
  Classes of Joseluis Laso   PHP Telegram CLI Wrapper   test/addContact.php   Download  
File: test/addContact.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Telegram CLI Wrapper
Send messages and other commands to Telegram users
Author: By
Last change:
Date: 8 years ago
Size: 649 bytes
 

Contents

Class file image Download
<?php

if ($argc < 3) {
    die (
"You have to invoke this program with addContact.php phone_number last_name first_name\n");
}

include_once
__DIR__ . '/../vendor/autoload.php';

use
TelegramCliWrapper\TelegramCliWrapper;
use
TelegramCliWrapper\TelegramCliHelper;
use
TelegramCliWrapper\Models\Dialog;

$phone = $argv[1];
$peerSurname = $argv[2];
$peerName = $argv[3];

if (!
preg_match("/^\+\d+/", $phone)){
    die(
"Phone number must be: plus sign (+) country_code & number\n");
}

$th = TelegramCliHelper::getInstance();
$t = new TelegramCliWrapper($th->getSocket(), $th->isDebug());

$t->add_contact($phone, $peerName, $peerSurname);

$t->quit();