yaroslavche / phptdlib Goto Github PK
View Code? Open in Web Editor NEWPHP Extension for tdlib/td written with PHP-CPP
Home Page: https://yaroslavche.github.io/phptdlib/
License: MIT License
PHP Extension for tdlib/td written with PHP-CPP
Home Page: https://yaroslavche.github.io/phptdlib/
License: MIT License
How to call TDApi in the php script ?
Fatal error: Uncaught Error: Class 'TDApi\LogConfiguration' not found
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
fatal: clone of 'git://github.com/nlohmann/json.git' into submodule path '/root/phptdlib/modules/json' failed
Failed to clone 'modules/json'. Retry scheduled
Cloning into '/root/phptdlib/modules/td'...
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
fatal: clone of 'git://github.com/tdlib/td.git' into submodule path '/root/phptdlib/modules/td' failed
Failed to clone 'modules/td'. Retry scheduled
Cloning into '/root/phptdlib/modules/json'...
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
fatal: clone of 'git://github.com/nlohmann/json.git' into submodule path '/root/phptdlib/modules/json' failed
Failed to clone 'modules/json' a second time, aborting
Can you take a look at this please?
This isn't really an issue. I just wanted to say that I added support for tdlib to my install-php-extensions
script.
That way, you can install the extension in Docker images simply by running
install-php-extensions tdlib
References:
PS: feel free to close this issue 😉
It is not trivial, but it is covered in tdlib documentation. We have to add it to our documentation
$chat_id=-1001190992756;
$message_text = 'hello';
$print_timeout = 1;
$client->query(json_encode([
'@type'=>'openChat',
'chat_id'=>$chat_id
]));
$client->query(json_encode([
'@type' => 'sendChatAction',
'chat_id' => $chat_id,
'action' => [
'@type' => 'chatActionTyping'
]
]));
sleep(1);
$client->query(json_encode([
'@type' => 'sendChatAction',
'chat_id' => $chat_id,
'action' => [
'@type' => 'chatActionCancel'
]
]));
$res=$client->query(json_encode([
'@type'=>'sendMessage',
'chat_id'=>$chat_id,
'reply_to_message_id'=>0,
'disable_notification'=>false,
'from_background'=>false,
'input_message_content'=>[
'@type'=>'inputMessageText',
'text'=>[
'@type'=>'formattedText',
'text'=>$message_text,
'entities'=>[]
],
'disable_web_page_preview'=>false,
'clear_draft'=>false
]
]));
$client->query(json_encode([
'@type' => 'closeChat',
'chat_id' => $chat_id
]));
if(!empty($res['last_message']['sendingState']) && $res['last_message']['sendingState']['@type']==='messageSendingStateFailed') {
throw new Exception('Message sending failed');
}
Originally posted by @maxvgi in #27 (comment)
Добрый день!
Неделю назад столкнулись с проблемой, что в нашем приложение после вызова setAuthenticationPhoneNumber на указанный номер перестали приходить коды для входа, хотя судя по логам TDlib код был успешно отправлен и статус в нашем приложение сменился на authorizationStateWaitCode.
Позже выяснилось что код приходит только в 5 % случаях (примерно). т.е. на например на номер ххх сегодня код не приходит (естественно после у нас есть около 5 попыток в сутки) а через пару дней приходит, но только один или два раза а потом перестает приходить (до выхода лимита на отправку по этому номеру).
Закономерность совершенно не понятна, тестировали с множеством разных телефонных номеров как и в РФ так и за пределами. В начали грешили на сервер и API ключи, но когда развернули новый сервер с полностью новыми API ключами (запустили только кусок кода с отправкой auth code ) тоже самое - точнее с новыми вообще не разу код не пришел, хотя судя же по логам код отправляется. TDLIB и PHP TDLIB у нас последней версии.
Может у вас есть какие то идеи почему это может происходить? А то у нас уже варианты кончились да и поддержка tdlib не может помочь.
Вот если что ветка issue на tdlib репозитории tdlib/td#925
I followed your build instruction:
git clone --recurse-submodules https://github.com/yaroslavche/phptdlib.git
cd phptdlib && mkdir build && cd build
cmake ..
make
when I run the make command I got this error message:
[ 71%] Building CXX object modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
modules/td/CMakeFiles/tdcore.dir/build.make:2534: recipe for target 'modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o' failed
make[2]: *** [modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o] Error 4
CMakeFiles/Makefile2:353: recipe for target 'modules/td/CMakeFiles/tdcore.dir/all' failed
make[1]: *** [modules/td/CMakeFiles/tdcore.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
How can I solve this issue?
Thanks
I try using library as in your example, but always getting exception "Timeout waiting for response" on line $client->setAuthenticationPhoneNumber($phone_number); or in other case $query = json_encode(['@type' =>'setAuthenticationPhoneNumber ','phone_number' => 'xxx']); $result = $client->query($query, 10);
Could you tell, how can resolve it?
Thank you
I tried to use phptdlib, but the classes in TDLib and TDApi are not visible to use.
Error:
Fatal error: Uncaught Error: Class 'TDApi\LogConfiguration' not found in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php:13 Stack trace: #0 {main} thrown in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php on line 13
Fatal error: Uncaught Error: Class 'TDLib\JsonClient' not found in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php:15 Stack trace: #0 {main} thrown in /Applications/AMPPS/www/td/phptdlib/php_examples/client.php on line 15
Does your extension has this ability to sign in with a phone number ?
i think phptdlib
need more example. example for forward
, download/upload
a large file and some more regular user action in telegram setting
such as proxy
manipulation, ...
Hi all,
I try to call 'getChat' method with "@channel_name" as chat_id (as far as I understand for public channels chat_id is the same as "@channel_name") but I receive an error: "Failed to parse JSON object as TDLib request: Can't parse "@channel_name" as number". If I can't use channel name as chat_id, where can I get channel's numeral id (I didn't find it in channel info section)?
Thanks for help in advance!
hello @yaroslavche I hope you are very well
this is to ask the next question.
add a new contact to my telegram data with the following code
$addContact = $client->query(json_encode(['@type' => 'importContacts', 'contacts' => [
[
'phone_number' => '+584145782661',
],
]]), 10);
the contact is saved successfully and gives me the user_id
"{"@type":"importedContacts","user_ids":[795223843],"importer_count":[0],"@extra":719885386}"
now I have the contact just added to my telegram.
said contact does not have a username.
at the moment I only know your user_id
what was the result that I threw when I added the contact
from my application that I am building I want to send a message to said contact just added
indicating
"Hi, I'm Deibis and I want to thank you for joining my blog."
in order to send a message I know that I must use the sendMessage class
the code would be as follows
$sendMesj=$client->query(json_encode([
'@type'=>'sendMessage',
'chat_id'=>"I don't know the chat_id only the user_id",
'reply_to_message_id'=>0,
'disable_notification'=>false,
'from_background'=>false,
'input_message_content'=>[
'@type'=>'inputMessageText',
'text'=>[
'@type'=>'formattedText',
'text'=>'Hi, I'm Deibis and I want to thank you for joining my blog.',
'entities'=>[]
],
'disable_web_page_preview'=>false,
'clear_draft'=>false
]
]));
what is the problem that it presented
that in order to send a message I must know the chat_id, but when I add the contact it does not give me a chat_id, it only gives me the user_id
the question is:
How can I send a message to a newly added contact?
Greetings.
Hi there!
Thanks for your extension.
I have a problem with query
method. I trying to call getChats
tdlib method and in result I see the object of updateFile @type.
What is wrong?
Authorization state is Ready
// Setting parameters and Database Encryption Key above
$offset = 9223372036854775807;
$result = $client->query(json_encode(['@type' => 'getChats', 'offset_order' => $offset, 'limit' => 10]), 10);
echo "<pre>"; print_r(json_decode($result)); die();
$client->destroy();
die();
By the way after calling any methods returning an "EXCEPTION" text. You can see in on my screenshot above. Feel like it from here https://github.com/yaroslavche/phptdlib/blob/master/include/TDLib/JsonClient.cpp#L37
Thanks for your time!
Failed to find php-config while make the project with cmake
Please add example callback php script definition on new message event.
Hi!
I've encountered the problem with the newest version of phptdlib not being able to ->setParameter(TDApi\TDLibParameters::API_ID, $api_id)
. Unfortunately, Yaroslav himself doesn't yet have a solution to this problem. I suspect there's some change in data types for API_IDs in the newest versions of https://github.com/tdlib/td/, which is a sub-module of this project.
But, I've managed to find a temporary solution to the problem. All you have to do is make sure that you're using a much older version of the td
submodule, that still worked without issues back in May 2022. I chose version 1.8.3 and made a fork:
https://github.com/AlexGnatko/td/
To apply the fix, go to the .gitmodules
file and change the td
url to https://github.com/AlexGnatko/td.git
.
Then run the following commands:
git submodule sync --recursive
cd modules/td
git fetch
git checkout origin/master
git branch master -f
git checkout master
And then follow the build steps listed in the readme file.
For me, it fixed the problem, and even though I don't have a recent version of TDLib compiled into phptdlib, I can at least use most of the Telegram functions in my PHP.
I hope this helps anyone who bumps into a similar problem.
I just tried this according to the example and I get along until I receive the verification code via SMS, enter that but I get stuck on the authorization_state
= authorizationStateWaitRegistration
. The searchPublicChat
example query fails with {"@type":"error","code":401,"message":"Unauthorized","@extra":424238335}
accordingly. This seems to be new and unfortunately not well documented anywhere. This is the reference in the API: https://core.telegram.org/tdlib/docs/classtd_1_1td__api_1_1accept_terms_of_service.html
[ 1][t 0][1564741364.083082199][ClientJson.cpp:89] Failed to parse [request:{\0042@type\0042:\0042getLogVerbosityLevel\0042}] [Error : 0 : Unknown class]
Probably need to update tdlib in submodules?
I install all the required dependencies in the project following the indications, but when I try to install phptdlib I get the following error:
CMake Error at CMakeLists.txt:9 (find_package):
By not providing "FindTd.cmake" in CMAKE_MODULE_PATH this project has asked
CMake to find a package configuration file provided by "Td", but CMake did
not find one.
Could not find a package configuration file provided by "Td" (requested
version 1.3.0) with any of the following names:
TdConfig.cmake
td-config.cmake
Add the installation prefix of "Td" to CMAKE_PREFIX_PATH or set "Td_DIR" to
a directory containing one of the above files. If "Td" provides a separate
development package or SDK, be sure it has been installed.
-- Configuring incomplete, errors occurred!
I have a "MacOS High Sierra v. 10.13.6 with Xcode updated and OpenSSL installed.
https://github.com/yaroslavche/phptdlib/blob/master/CMakeLists.txt
https://yaroslavche.github.io/phptdlib/installation.html#scripts-install
php:^7.4|^8.0 or even just 8.0 is fine
I am trying to run a basic example, i.e. client.php and I have configured credentials.php, but the script keeps crashing. Tried with other phone number to no avail.
(Xdebug message)
"{"@type":"error","code":400,"message":"PHONE_NUMBER_FLOOD","@extra":1234567899}"
[27] =>
Any chance to make calls via this lib,
like this https://github.com/grishka/libtgvoip ?
Would it be possible to upgrade the tdlib submodule from v1.4.0 to v1.5.0? I tested locally and the it compiles fine, except for deprecation warnings. The following methods are deprecated in v1.5.0:
td_set_log_file_path();
td_set_log_max_file_size();
td_set_log_verbosity_level();
Could you give some example for sendMessage?
following is not work
$chat_id=-1001190992756;
$msg = (object)['hello'];
$client->query(json_encode( ['@type' => 'sendMessage', 'chat_id' => $chat_id, 'input_message_content' => $msg, ), 10);
i see:
[ 1][t 0][1548776841.107118130][ClientJson.cpp:71] Failed to parse [request:{\0042@extra\0042:1.01234,\0042@type\0042:\0042sendMessage\0042,\0042chat_id\0042:-1001190992756,\0042input_message_content\0042:{\00420\0042:\0042hello\0042}}] [Error : 400 : Can't find field "@type"]
Hello, i have compiled latest PHP-CPP v2.0.0 and phptdlib
when i invoke importContacts i get error
$addContact = $client->query(json_encode(['@type' => 'importContacts', 'contacts' => [ [ 'phone_number' => '+12133123456', ], ]])); var_dump(json_encode($addContact));
"{"@type":"error","code":429,"message":"Too Many Requests: retry after 3600","@extra":xxxx}"
but next line is invoke without error
$getMe = $client->query(json_encode(['@type' => 'getMe'])); var_dump(json_encode($getMe));
"{"@type":"user","id":xxxxx,"first_name":"......
when i try
$addContact = $client->query(json_encode(['@type' => 'importContacts', ['contacts' => [ [ 'phone_number' => '+12133942853', ], ]]])); var_dump(json_encode($addContact));
"{"@type":"importedContacts","user_ids":[],"importer_count":[],"@extra":xxxx}"
Could you suggest the correct call to the importContacts function or there may be an error in something else.
tip:
[ 44%] Building CXX object modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o
c++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.
modules/td/CMakeFiles/tdcore.dir/build.make:1934: recipe for target 'modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o' failed
make[2]: *** [modules/td/CMakeFiles/tdcore.dir/td/telegram/MessagesManager.cpp.o] Error 4
CMakeFiles/Makefile2:325: recipe for target 'modules/td/CMakeFiles/tdcore.dir/all' failed
make[1]: *** [modules/td/CMakeFiles/tdcore.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
Got
string(563) "{"@type":"updateAuthorizationState","authorization_state":{"@type":"authorizationStateWaitRegistration","terms_of_service":{"@type":"termsOfService","text":{"@type":"formattedText","text":"By signing up for Telegram, you agree not to:\n\n- Use our service to send spam or scam users.\n- Promote violence on publicly viewable Telegram bots, groups or channels.\n- Post pornographic content on publicly viewable Telegram bots, groups or channels.\n\nWe reserve the right to update these Terms of Service later.","entities":[]},"min_user_age":0,"show_popup":false}}}"
while running client.php
Changes in 1.5.0:
Changed authorization workflow:
Added the state authorizationStateWaitRegistration, which will be received after authorizationStateWaitCode for users who are not registered yet.
Added the method registerUser, which must be used in the authorizationStateWaitRegistration state to finish registration of the user.
When I build phptdlib (cmake .. in phptdlib/build), I get this error:
CMake Error at CMakeLists.txt:111 (find_package):
Could not find a configuration file for package "Td" that is compatible
with requested version "1.6.9".
The following configuration files were considered but not accepted:
/usr/local/td/TdConfig.cmake, version: unknown
How can I fix it?
Hi, and Thank you for this incredible library!
I've built it, and compiled it successfully, and also logged in .
Everything is fine!
I'm trying to upload a profile photo for my telegram account. but here is the result:
something goes wrong: Error parsing json
I know that I am doing something wrong about inputPhoto but although reading the whole document , I have no idea how to implement the image that can be parsed by Json class.
Here is the part of code:
$image=imagecreatefrompng("candle.png");
$result = $client->query(json_encode(['@type' => 'setProfilePhoto', 'photo' => $image]), 10);
var_dump($result);
and I wish if you could show me an example of setProfilePhoto, just like the example of sendMessage in your documentation.
Thank you for your time.
Hello dear, I hope this is very good.
This is to ask if the phptdlib library can be integrated with laravel.
since I have been doing full tests with laravel commands but it always tells me that the class 'TDApi \ LogConfiguration' not found
It should be noted that the .php file that contains the configuration of the API_ID and HAS of telegram when I run it directly in the console if it gives me a successful connection.
but when I do a test from the laravel command it tells me class 'TDApi \ LogConfiguration' not found
Regards.
How can I run the main script on the server? Should I call it from the terminal, or is there another way
Hi.
I build for Fedora 28 or Centos 7.
Check error:
[root@localhost build]# php -i | grep tdlib
PHP Warning: PHP Startup: Unable to load dynamic library 'tdlib.so' (tried: /usr/lib64/php/modules/tdlib.so (/usr/lib64/php/modules/tdlib.so: undefined symbol: _ZN14BaseJsonClient12__callStaticEPKcRN3Php10ParametersE), /usr/lib64/php/modules/tdlib.so.so (/usr/lib64/php/modules/tdlib.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
any idea
Доброго времени суток!
Если возможность авторизавать без кода подтверждения с помощью PUBLIC KEY.
Взял пример с https://yaroslavche.github.io/phptdlib/documentation.html (TDLib\JsonClient)
Запускаю php ../php_examples/test.php
Ответ:
[32]=>
string(266) "{"@type":"authorizationStateWaitCode","code_info":{"@type":"authenticationCodeInfo","phone_number":"7XXXXXXXXXX","type":{"@type":"authenticationCodeTypeSms","length":5},"next_type":{"@type":"authenticationCodeTypeCall","length":0},"timeout":120},"@extra":1957747793}"
[33]=>
string(72) "{"@type":"error","code":401,"message":"Unauthorized","@extra":424238335}"
Что с этим можно сделать?
Подскажите пожулуста)
Hello, how can I get updates in real time from other telegram users?
https://core.telegram.org/tdlib/getting-started#handling-updates
For example:
while (1) {
$response = $client->getOtherUsersUpdates()
switch ($response) {
case ('updateUser'): // other user is online
case ('updateNewMessage'): // other user sent me a message
...
}
}
this function $client->getReceivedResponses() return empty results in loop
my example:
TDApi\LogConfiguration::setLogVerbosityLevel(\TDApi\LogConfiguration::LVL_ERROR);
$client = new TDLib\JsonClient();
$tdlibParams = new TDApi\TDLibParameters();
$tdlibParams
->setParameter(TDApi\TDLibParameters::USE_TEST_DC, true)
->setParameter(TDApi\TDLibParameters::DATABASE_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::FILES_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::USE_FILE_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_CHAT_INFO_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_MESSAGE_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_SECRET_CHATS, false)
->setParameter(TDApi\TDLibParameters::API_ID, $api_id)
->setParameter(TDApi\TDLibParameters::API_HASH, $api_hash)
->setParameter(TDApi\TDLibParameters::SYSTEM_LANGUAGE_CODE, 'en')
->setParameter(TDApi\TDLibParameters::DEVICE_MODEL, php_uname('s'))
->setParameter(TDApi\TDLibParameters::SYSTEM_VERSION, php_uname('v'))
->setParameter(TDApi\TDLibParameters::APPLICATION_VERSION, '0.0.10')
->setParameter(TDApi\TDLibParameters::ENABLE_STORAGE_OPTIMIZER, true)
->setParameter(TDApi\TDLibParameters::IGNORE_FILE_NAMES, false);
$result = $client->setTdlibParameters($tdlibParams);
$result = $client->setDatabaseEncryptionKey(); // checkDatabaseEncryptionKey(key) or DESTROY
$result = $client->getAuthorizationState();
while (true) {
sleep(1);
$r = $client->getReceivedResponses();
var_dump($r); // it's empty after a while
}
Thank you!
I run the following code and always return a timeout. I checked that my proxy settings are normal, and the proxy test using curl is also normal, but the request to verify the phone number interface always times out. The code is as follows:
$api_id = xxxx; // must be an integer
$phone_number = '+xxxxx';
$api_hash = 'd9f9633f6eaxxxxxx';
try {
TDApi\LogConfiguration::setLogVerbosityLevel(\TDApi\LogConfiguration::LVL_ERROR);
$client = new TDLib\JsonClient();
$tdlibParams = new TDApi\TDLibParameters();
$tdlibParams
->setParameter(TDApi\TDLibParameters::USE_TEST_DC, false)
->setParameter(TDApi\TDLibParameters::DATABASE_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::FILES_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::USE_FILE_DATABASE, true)
->setParameter(TDApi\TDLibParameters::USE_CHAT_INFO_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_MESSAGE_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_SECRET_CHATS, false)
->setParameter(TDApi\TDLibParameters::API_ID, $api_id)
->setParameter(TDApi\TDLibParameters::API_HASH, $api_hash)
->setParameter(TDApi\TDLibParameters::SYSTEM_LANGUAGE_CODE, 'en')
->setParameter(TDApi\TDLibParameters::DEVICE_MODEL, php_uname('s'))
->setParameter(TDApi\TDLibParameters::SYSTEM_VERSION, php_uname('v'))
->setParameter(TDApi\TDLibParameters::APPLICATION_VERSION, '0.0.10')
->setParameter(TDApi\TDLibParameters::ENABLE_STORAGE_OPTIMIZER, true)
->setParameter(TDApi\TDLibParameters::IGNORE_FILE_NAMES, false);
//var_dump($tdlibParams);die;
$result = $client->setTdlibParameters($tdlibParams);
$result = $client->setDatabaseEncryptionKey(); // checkDatabaseEncryptionKey(key) or DESTROY
// UNCOMMENT NEXT and COMMENT PREVIOUS LINES WHEN RECEIVE SMS. Set your data
// $result = $client->query(json_encode(['@type' => 'checkAuthenticationCode', 'code' => 'xxxxx', 'first_name' => 'dummy', 'last_name' => 'dummy']), 10);
// var_dump($result);die;
$proxy = [
'@type' => 'proxyTypeSocks5',
'username' => '',
'password' => '',
];
$res = $client->query(json_encode([
'@type' => 'addProxy',
'server' => 'xxxxxx',
'port' => 1080,
'enable' => true,
'type' => $proxy
]), 10);
//var_dump($res);die;
$query = json_encode([
'@type' => 'setAuthenticationPhoneNumber',
'phone_number' => $phone_number,
]);
// $r=$client->setDefaultTimeout(30);
$result = $client->query($query,60);
var_dump($result);die;
The error log is as follows:
PHP Fatal error: Uncaught Exception: Timeout waiting for response in /home/wwwroot/default/send.php:53
Stack trace:
#0 /home/wwwroot/default/send.php(53): TDLib\JsonClient->query('{"@type":"setAu...', 3)
#1 {main}
thrown in /home/wwwroot/default/send.php on line 53
Fatal error: Uncaught Exception: Timeout waiting for response in /home/wwwroot/default/send.php:53
Stack trace:
#0 /home/wwwroot/default/send.php(53): TDLib\JsonClient->query('{"@type":"setAu...', 3)
#1 {main}
thrown in /home/wwwroot/default/send.php on line 53
I don't know why sometimes the message is not delivered.
I check the response and I get the right json which shows no difference between that is sent and what remains suspended.
When I try to send another one, just now it sends the previous messages plus the new one.
So, it seems like they stay in the box and when prompted by a new message they wake up and go all together.
I would like to know if there is a way to push all messages or if I miss something to send message in the correct way.
Thanks
fatal error: 'phpcpp.h' file not found #include <phpcpp.h> ^~~~~~~~~~ 1 error generated. make[2]: *** [CMakeFiles/tdlib.dir/tdlib.cpp.o] Error 1 make[1]: *** [CMakeFiles/tdlib.dir/all] Error 2 make: *** [all] Error 2
run cat /usr/local/include/phpcpp/version.h
:
cat /usr/local/include/phpcpp/version.h
/**
* Version.h
*
* Macro with API version. The API version number prevents that
* extensions are loaded that are incompatible with the libphpcpp.so
* library
*
* @author Emiel Bruijntjes <[email protected]>
* @copyright 2015 Copernica BV
*/
/**
* Macro with version number (this is incremented with every release)
*/
#define PHPCPP_API_VERSION 20150126
run cat /usr/include/phpcpp/version.h
:
cat /usr/include/phpcpp/version.h
cat: /usr/include/phpcpp/version.h: No such file or directory
my os : macos Catalina 10.15.4
Hello, I'm trying to use this library. When using BOT to call download_File, I'll prompt: file download has failed. I'm trying to run in cli mode. The result is still the same. I don't know where the cause is. Please
Why when i call method getChat returns Chat.order
equals "0"?
получилось только с обыной группы, а вот с супер групп и остального нет.
Подскажите пожалуйста
PROBLEM: trying to make in Debian 11, PHP 7.4 got the errors:
[ 97%] Building CXX object CMakeFiles/tdlib.dir/include/TDLib/BaseJsonClient.cpp.o
In file included from /usr/include/phpcpp.h:38,
from /opt/phptdlib/include/TDLib/BaseJsonClient.hpp:4,
from /opt/phptdlib/include/TDLib/BaseJsonClient.cpp:1:
/usr/include/phpcpp/throwable.h:29:1: error: expected class-name before ‘{’ token
29 | {
| ^
/usr/include/phpcpp/throwable.h: In constructor ‘Php::Throwable::Throwable(const string&)’:
/usr/include/phpcpp/throwable.h:43:63: error: expected class-name before ‘(’ token
43 | Throwable(const std::string &message) : std::runtime_error(message) {}
| ^
/usr/include/phpcpp/throwable.h:43:63: error: expected ‘{’ before ‘(’ token
make[2]: *** [CMakeFiles/tdlib.dir/build.make:95: CMakeFiles/tdlib.dir/include/TDLib/BaseJsonClient.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:443: CMakeFiles/tdlib.dir/all] Error 2
make: *** [Makefile:149: all] Error 2
SOLUTION:
Edit file /usr/include/phpcpp/throwable.h
and add the line:
#include <stdexcept>
Hello
Thanks for your project
I have installed PHP-CPP
but I recieve this error:
root@mygr:~/projects/phptdlib/build# cmake ..
CMake Error at CMakeLists.txt:15 (message):
Failed to find PHP-CPP
-- Configuring incomplete, errors occurred!
See also "/root/projects/phptdlib/build/CMakeFiles/CMakeOutput.log".
good morning dear.
this is to request a help to add a contact with phptdlib
I am using the following:
$obj3 = (object)[
'phone_number' => '+584145782661',
'first_name' => 'fernando',
'last_name' => 'moutinho',
'vcard' => [],
'user_id' => 0];
$testencode = json_encode($obj3);
//var_dump($testencode);
$addContact = $client->query(json_encode(['@type' => 'addContact', ['contact' => $testencode]]), 10);
but it shows me the following error message
"{"@type":"error","code":5,"message":"Contact must be non-empty","@extra":1714636915}"
I also tried the contact class
$contact = $client->query(json_encode(['@type' => 'contact', [
'phone_number' => '+584145782661',
'first_name' => 'fernando',
'last_name' => 'moutinho',
'vcard' => [],
'user_id' => 0
]]), 10);
but it shows me the following error message
"{"@type":"error","code":400,"message":"Failed to parse JSON object as TDLib request: Unknown class "contact"","@extra":1714636915}"
Please could you help me.
or make an example of how to add a contact with phptdlib
thanks greetings.
I have errors during the compilation of phptdlib. I use a MacOS HighSierra v. 10.13.6.
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR)
CMake Warning at modules/td/CMakeLists.txt:249 (message):
Not found OpenSSL: skip TDLib, tdactor, tdnet, tddb
-- Using the single-header code from /Applications/MAMP/htdocs/TelegramRecorder/phptdlib/modules/json/single_include/
CMake Error at CMakeLists.txt:175 (install):
install FILES given no DESTINATION!
-- Configuring incomplete, errors occurred!
The first error (OPEN SSL) managed to solve it with:
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
But the error "install FILES given no DESTINATION!" I do not know what can be caused or how to solve it.
Hi!
Can you update phptdlib for tdlib 1.6.0 support?
There is few very interesting features.
Thank you.
Hello
I've been trying to install this very useful library on my server since morning but there's a problem I can't get it fixed, so it would be appreciated if you give me a hand.
After installation of the required items, when installing the extension itself, in the step when I enter the command 'make' it gets stuck on Installation of one of the objects:
Building CXX object modules/td/CMakeFiles/tdcore.dir/td/telegram/AnimationsManager.cpp.o
Almost 1 hour took and then finally I canceled it.
during the installation of this file my CPU usage has been on 100%, used ram is 1.8GB out of 2GB (when not installing the used ram is at most 300MB) and hard drive is reading at the speed of 550MB/s
Thank you.
In the next step I get this error:
root@mygr:~/projects/phptdlib/php_examples# php client.php
php: symbol lookup error: /usr/lib/php/20151012/tdlib.so: undefined symbol: _ZN2td3Log19set_verbosity_levelEi
Can you please give an example of how to connect to telegram ?
Как избавиться от ошибки "Timeout waiting for response"?
Сначала она была редкой, теперь в 8/10 случаев я не могу получить данные
$this->client->setDefaultTimeout(60); - уставновил
`try {
TDApi\LogConfiguration::setLogVerbosityLevel(\TDApi\LogConfiguration::LVL_ERROR);
$this->client = new TDLib\JsonClient();
// $this->client->getAuthorizationState();
$tdlibParams = new TDApi\TDLibParameters();
$tdlibParams
->setParameter(TDApi\TDLibParameters::USE_TEST_DC, false)
->setParameter(TDApi\TDLibParameters::DATABASE_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::FILES_DIRECTORY, '/var/tmp/tdlib')
->setParameter(TDApi\TDLibParameters::USE_FILE_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_CHAT_INFO_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_MESSAGE_DATABASE, false)
->setParameter(TDApi\TDLibParameters::USE_SECRET_CHATS, false)
->setParameter(TDApi\TDLibParameters::API_ID, $this->api_id)
->setParameter(TDApi\TDLibParameters::API_HASH, $this->api_hash)
->setParameter(TDApi\TDLibParameters::SYSTEM_LANGUAGE_CODE, 'en')
->setParameter(TDApi\TDLibParameters::DEVICE_MODEL, php_uname('s'))
->setParameter(TDApi\TDLibParameters::SYSTEM_VERSION, php_uname('v'))
->setParameter(TDApi\TDLibParameters::APPLICATION_VERSION, '0.0.10')
->setParameter(TDApi\TDLibParameters::ENABLE_STORAGE_OPTIMIZER, true)
->setParameter(TDApi\TDLibParameters::IGNORE_FILE_NAMES, false);
$this->client->setTdlibParameters($tdlibParams);
$this->client->setDefaultTimeout(30);
$this->client->setDatabaseEncryptionKey(); // checkDatabaseEncryptionKey(key) or DESTROY
} catch (\Exception $exception) {
echo sprintf('something goes wrong: %s', $exception->getMessage());
}`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.