Giter Club home page Giter Club logo

jadopado-telegram's Introduction

PHP real time chat using the Telegram API

This is based on Telegram CLI wrapper ( vysheng/tg ), built on top of the Telegram API - http://core.telegram.org/api

Steps to install

  1. Install Telegram CLI wrapper https://github.com/vysheng/tg/blob/master/README.md#installation

  2. Goto your tg directory and create 2 profiles named profileadmin and profilecustomer respectively.

    • Create two directories -
      • create folder "profileadmin"
      • create folder "profilecustomer"
  3. Initial profile setup for profileadmin account

tg/bin/telegram-cli -k tg/tg-server.pub -c tg/config -p profileadmin --json -I -R -C -P 3000

Initial profile setup for profilecustomer account

tg/bin/telegram-cli -k tg/tg-server.pub -c tg/config -p profilecustomer --json -I -R -C -P 3001

You are ready to run the telegram monitoring service

php telegram_service.php -v

Open another terminal and run

php telegram_service.php -c -v

Sample tg config

default_profile = "profileadmin";
profileadmin = {
  config_directory = "/path/tg/profileadmin";
  msg_num = true;
  binlog_enabled = true;
};

profilecustomer = {
  config_directory = "/path/tg/profilecustomer";
  msg_num = true;
  binlog_enabled = true;
};

Sample php code to test the service

<?
try{
$telegram = new Helper();

$data = array();
$chat_topic = 'This is a new group';
$data['chat_topic'] = $chat_topic ;
$telegram->create_group_chat($data);
$chat_id = $telegram->get_chat_id($chat_topic);
$telegram->send_message_to_group($chat_id,'test message',$telegram->admin_service_port);

}catch(Exception $e){
	echo $e->getMessage();
}
?>

Sample config

<?
define('ADMIN_ID','YOUR_TELEGRAM_USER_ID');
define('CUSTOMER_ID','YOUR_CUSTOMER_USER_ID');
define('ADMIN_PORT','Admin service port number');/* eg .. 3000 */
define('CUSTOMER_PORT','Client service port number');/* eg .. 3001 */
define('HOST','localhost');
define('LOG_PATH','logs/info.txt');
?>

Acknowledgements

This integration depends on Vygeng's Telegram-CLI (https://github.com/vysheng/tg) and on the core Telegram API

jadopado-telegram's People

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.