File: public/profile.php

Recommend this page to a friend!
  Classes of Joseluis Laso  >  PHP Telegram CLI Wrapper  >  public/profile.php  >  Download  
File: public/profile.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: 4 years ago
Size: 935 bytes
 

Contents

Download
<?php

session_start
();

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

use
TelegramCliWrapper\TelegramCliWrapper;
use
TelegramCliWrapper\TelegramCliHelper;
use
TelegramCliWrapper\Storage\LocalFilesStorage;
use
TelegramCliWrapper\Response;
use
TelegramCliWrapper\Models\User;

if (!isset(
$_SESSION['user'])) {
    return
Response::error("illegal request");
}

$userStorage = new LocalFilesStorage('user');
$user = $userStorage->getById($_SESSION['user']);

if (!
$user) {
    return
Response::error("user does not exist");
}

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

$user = $t->getUserInfo($user->phone);
$result = array(
   
'phone' => $user->phone,
   
'last_name' => $user->last_name,
   
'first_name' => $user->first_name,
   
'print_name' => $user->print_name,
   
'id' => $user->id,
   
'flags' => $user->flags,
);

return
Response::ok(array('user' => $result));


For more information send a message to info at phpclasses dot org.