Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit 150962b

Browse files
committed
Updated README.md and example.php
1 parent 4dee0bc commit 150962b

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ For this example we will take the following command (execute it from the dir, wh
2424
./bin/telegram-cli --json -dWS /tmp/tg.sck &
2525
```
2626

27+
If you run the telegram-cli under another user than your php-script and you are using linux, you need to change the rights of the socket so that the php-script can access it. For example, add both to a `telegram`-group and then do
28+
29+
```shell
30+
chown :telegram /tmp/tg.sck
31+
chmod g+rwx /tmp/tg.sck
32+
```
33+
2734
If you never started telegram-cli before, you need to start it first in normal mode, so you can type in your telegram-phone-number and register it, if needed (`./bin/telegram-cli`).
2835

2936
To stop the daemon use `killall telegram-cli` or `kill -TERM [telegram-pid]`.
@@ -32,10 +39,11 @@ To stop the daemon use `killall telegram-cli` or `kill -TERM [telegram-pid]`.
3239
In your project-root:
3340

3441
```shell
35-
composer require zyberspace/telegram-cli-client
42+
composer require --update-no-dev zyberspace/telegram-cli-client
3643
```
3744

38-
Composer will then automatically add the package to your project requirements and install it (also creates the `composer.json` if you don't have one already).
45+
Composer will then automatically add the package to your project requirements and install it (also creates the `composer.json` if you don't have one already).
46+
If you want to use the discovery-shell, remove the `--update-no-dev` from the command.
3947

4048
###Use it
4149

@@ -44,7 +52,25 @@ require('vendor/autoload.php');
4452
$telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');
4553

4654
$contactList = $telegram->getContactList();
47-
$telegram->msg($contactList[0], 'Hey man, what\'s up? :D');
55+
$telegram->msg($contactList[0]->print_name, 'Hey man, what\'s up? :D');
56+
```
57+
58+
###Use it with the discovery-shell
59+
A really easy way to learn the api is by using the embedded [discover-shell](https://github.com/zyberspace/php-discovery-shell). You need to install the dev-dependencies for this (`composer update --dev`).
60+
61+
```shell
62+
$ ./discovery-shell.php
63+
-- discovery-shell to help discover a class or library --
64+
65+
Use TAB for autocompletion and your arrow-keys to navigate through your method-history.
66+
Beware! This is not a full-featured php-shell. The input gets parsed with PHP-Parser to avoid the usage of
67+
eval().
68+
> $telegram->getContactList();
69+
array(13) {
70+
[...]
71+
}
72+
> $telegram->msg('my_contact', 'Hi, i am sending this from a php-client for telegram-cli.');
73+
true
4874
```
4975

5076
Documentation

example.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
$contactList = $telegram->getContactList();
1313
var_dump($contactList);
1414

15-
var_dump($telegram->msg($contactList[0], '"Te\'st"' . "\n" . time()));
15+
var_dump($telegram->msg($contactList[0]->print_name, '"Te\'st"' . "\n" . time()));

0 commit comments

Comments
 (0)