Giter VIP home page Giter VIP logo

madelineproto's Introduction

MadelineProto, a PHP MTProto telegram client

Created by Daniil Gentili

#StandWithUkraine 🇺🇦

Do join the official channel, @MadelineProto and the support groups!

Approved by Telegram!

What's this?

This library can be used to easily interact with Telegram without the bot API, just like the official apps.

It can login with a phone number (MTProto API), or with a bot token (MTProto API, no bot API involved!).

It is now fully async!

Getting started (now fully async!)

<?php

// PHP 8.2+ is required.

if (!file_exists('madeline.php')) {
    copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
}
include 'madeline.php';

$MadelineProto = new \danog\MadelineProto\API('session.madeline');
$MadelineProto->start();

$me = $MadelineProto->getSelf();

$MadelineProto->logger($me);

if (!$me['bot']) {
    $MadelineProto->messages->sendMessage(peer: '@stickeroptimizerbot', message: "/start");

    $MadelineProto->channels->joinChannel(channel: '@MadelineProto');

    try {
        $MadelineProto->messages->importChatInvite(hash: 'https://t.me/+Por5orOjwgccnt2w');
    } catch (\danog\MadelineProto\RPCErrorException $e) {
        $MadelineProto->logger($e);
    }
}
$MadelineProto->echo('OK, done!');

Try running this code in a browser or in a console!

Tip: if you receive an error (or nothing), send us the error message and the MadelineProto.log file that was created in the same directory (if running from a browser).

Made with MadelineProto

The following open source projects were created using MadelineProto: you can directly install them, or explore the source code as direct examples on how to use MadelineProto's many features!

Want to add your own open-source project to this list? Click here!

Documentation

madelineproto's People

Contributors

ahjdev avatar alexmorbo avatar andrew-ld avatar awesomebytes avatar chidea avatar danog avatar davtur19 avatar dependabot[bot] avatar github-actions[bot] avatar giuseppem99 avatar griganton avatar grizzly2212 avatar hbashton avatar henkgrent avatar lds56 avatar marcosramirezaranda avatar mix6s avatar mtalaeii avatar mugavri avatar painor avatar rik43 avatar saleh7 avatar savely-krasovsky avatar sea-n avatar veetaw avatar vitormattos avatar wecanco avatar wsudo avatar xcgu avatar xtrime-ru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

madelineproto's Issues

Could not extract type: Message with id 691184641

Error when executing testing.php

MTProto: Istantiating DataCenter...
MTProto: Loading RSA key...
RSA: Istantiating \phpseclib\Crypt\RSA...
RSA: Loading key...
RSA: Computing fingerprint...
RSA: Generating BigInteger object for fingerprint...
MTProto: Translating tl schemas...
TL: Loading TL schemes...
TL: Translating objects...
TL: Translating methods...
MTProto: Switching to DC 2...
DataCenter: Connecting to DC 2...
MTProto: Generating permanent authorization key...
AuthKeyHandler: Requesting pq
CallHandler: Getting response (try number 1 for req_pq)...
PrimeModule: Trying to use the python factorization module
AuthKeyHandler: Factorization 3166487665361386763 = 1714439161 * 1846952483
AuthKeyHandler: Starting Diffie Hellman key exchange
CallHandler: Getting response (try number 1 for req_DH_params)...
AuthKeyHandler: Server-client time delta = 0.0 s
AuthKeyHandler: Executing dh_prime checks...
CallHandler: Getting response (try number 1 for set_client_DH_params)...
AuthKeyHandler: Diffie Hellman key exchange processed successfully
AuthKeyHandler: Auth key generated
MTProto: Generating temporary authorization key...
AuthKeyHandler: Requesting pq
CallHandler: Getting response (try number 1 for req_pq)...
PrimeModule: Trying to use the python factorization module
AuthKeyHandler: Factorization 3552956053997046449 = 1821318677 * 1950760237
AuthKeyHandler: Starting Diffie Hellman key exchange
CallHandler: Getting response (try number 1 for req_DH_params)...
AuthKeyHandler: Server-client time delta = 0.0 s
AuthKeyHandler: Executing dh_prime checks...
CallHandler: Getting response (try number 1 for set_client_DH_params)...
AuthKeyHandler: Diffie Hellman key exchange processed successfully
AuthKeyHandler: Auth key generated
MTProto: Writing client info...
CallHandler: Getting response (try number 1 for invokeWithLayer)...
PHP Fatal error: Uncaught danog\MadelineProto\TL\Exception: Could not extract type: Message with id 691184641 in /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php:239
Stack trace:
#0 /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php(230): danog\MadelineProto\TL\TL->deserialize(Resource id #74, 'Message')
#1 /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php(249): danog\MadelineProto\TL\TL->deserialize(Resource id #74, 'vector', 'Message')
#2 /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/MTProtoTools/MessageHandler.php(110): danog\MadelineProto\TL\TL->deserialize(Resource id #74)
#3 /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/MTProtoTools/CallHandler.php(29): danog\MadelineProto\MTProtoTools\MessageHandler->recv_message()
#4 /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/MTProtoTools/CallHandler.php(70): danog\MadelineProto\MTProtoTools\CallHandler->wait_for_response(635430637815621222 in /var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/TL/TL.php on line 239

Support to 2fa

When the telegram number has 2-FA configured, the application return the error SESSION_PASSWORD_NEEDED and don't get the password to authenticate.

Send message options

Hi.
What do these options mean in sendMesssage method? (I couldn't be able to find anything about in the
docs)

  • background
  • reply_markup

Ability to restrict ipv6

When I use API in corporative network, client not worked. Maybe some firewall restrictions. ipv6.google.com is ok but client not worked untill I manually set ipv6 to false in source code.

content_related()

Hey. I wanted to ask about the function TL-> content_related(). How do you know that these questions are not related to the context?

Disable update saving

Hello @danog ,
Every update the client gets, MadelineProto saves (?) the update. Every time that I restart the program Madeline logs all updates and miss time, specially when there are a lot of updates (i receive 1 update every 2 seconds circa from my main account):

... ...
UpdateHandler, MyUsername:  	Handling an update of type updateNewMessage...
UpdateHandler, MyUsername:  	Saving an update of type updateNewMessage...
... ...

After one hour I have a 1324718 characters long-log of old and useless updates, and I miss ~10-15 seconds when I start the program. It's very annoying: if it isn't possible to stop "update saving", how can I stop receiving updates? I don't need this function, for now.

Error while sending messages

Hello @danog ,
I'm sending massive messages (1 per seconds) to my private bots (personal scopes) with my userbot. But, with updates disabled, after few minutes i have this error:

2017-02-09 18:45:26,925 [ERROR]: HTTP CODE: 500 #!/usr/bin/env php
MTProto:                Resetting session id and seq_no in DC 2...
MTProto:                Resetting session id and seq_no in DC 4...
CallHandler:            Calling method (try number 1 for messages.sendMessage)...
CallHandler:            Calling method (try number 1 for contacts.resolveUsername)...
ResponseHandler:        Received msg_container.
ResponseHandler:        Received new_session_created.
ResponseHandler:        Received msgs_ack.
ResponseHandler:        Receive rpc_result.

and the messages aren't sent.
My code:

#!/usr/bin/env php
<?php
require 'MadelineProto/vendor/autoload.php';
$settings = [];

$MadelineProto = \danog\MadelineProto\Serialization::deserialize('bot.madeline');

function sm($chatID, $text)
{
   global $MadelineProto;
   var_export($MadelineProto->messages->sendMessage(['peer' => $chatID, 'message' => $text]));
}

$peer = $_GET["peer"];
$message = $_GET["message"];
// $peer = "@marcobuster";
// $message = "Test";

sm($peer, $message);
?>

How to fix this?

Examples?

Hi. Can you put some examples? Like, sending message, or some other complex examples? Also on how the session of authorization works? Because testing.php keep doing authorization each time I ran it.

I am trying to send a message but can't figure out how to write it. Keep getting cannot serialize InputPeer. I dont have complete understanding on how to write it.
https://tjhorner.com/tl-schema/method/messages.sendMessage

Performance comparison: Running in the local vs host

Hi. I implemented python factorization for php. It's a bit slower, but that's ok. When I run telegram login in local environment, it takes about 15 seconds (and prime factorization itself takes about 1 second.)

But in host (linux, cpanel) the result is difference. Prime factorization runs very fast (about 0.3 second) , but the whole code (login) takes about 27 seconds (and sometimes takes very longer). I know maybe this is not a issue for MadelineProto , but maybe there is any idea about this.

And one more question: Why PrimeFactors (in PrimeModule.php) runs for 6 times?

An error occurred while calling method req_pq.

Hello,
i am getting this errors and i cant fix it.
Do you know an solution to this?

Kind regards

PHP Fatal error: Uncaught exception 'danog\MadelineProto\Exception' with message 'An error occurred while calling method req_pq.' in \src\danog\MadelineProto\Session.php:309
Port: string(3) "443"
Stack trace:
resource(35) of type (stream)
#0 src\danog\MadelineProto\Session.php(427): danog\MadelineProto\Session->method_call('req_pq', Array)
#1 src\danog\MadelineProto\Session.php(118): danog\MadelineProto\Session->create_auth_key(-1)
#2 src\danog\MadelineProto\API.php(24): danog\MadelineProto\Session->__construct(Array)
#3 src\modul\telegram\index.php(18): danog\MadelineProto\API->__construct(Array)
#4 {main}

thrown in src\danog\MadelineProto\Session.php on line 309

PHP Fatal error: Uncaught exception 'danog\PHP\StructException' with message 'An error occurred while packing -4294967296 at format key Q (Number is not within required range (0 <= number <= 1.844674407371E+19). on line 862).' in src\danog\PHP\StructTools.php:323
Stack trace:
#0 src\danog\MadelineProto\Session.php(206): danog\PHP\StructTools->pack('<Q', -4294967296)
#1 src\danog\MadelineProto\Session.php(294): danog\MadelineProto\Session->send_message('x\x97F`-\x98\x1AD\x8FI\x0EC\xE1E]...', true)
#2 src\danog\MadelineProto\Session.php(427): danog\MadelineProto\Session->method_call('req_pq', Array)
#3 src\danog\MadelineProto\Session.php(118): danog\ in src\danog\PHP\StructTools.php on line 323

auth.sendCode cannot receive sms_type as parameter

At your TL schema:
auth.sendCode#86aef0ec flags:# allow_flashcall:flags.0?true phone_number:string current_number:flags.0?Bool api_id:int api_hash:string = auth.SentCode;

At telegram official schema sms_type exists
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;

Problem in connecting to telegram api

Hi there. After struggling for some days, still I can not connect to telegram.
I installed dependencies by composer. Running the main index.php in the project, give me this error:

{"ok":false,"error_code":404,"error_description":"Invalid token provided"}

I read the docs and changed the codes:

$MadelineProto = new \danog\MadelineProto\API();
$MadelineProto->update_settings($settings);
$number = '+989380597197';
$sentCode = $MadelineProto->phone_login($number); // Send code
var_dump($sentCode);

$settings is the array that provided in the docs. I just changed api_id and api_hash to my own.

The result is this and nothing happened:

MTProto:        	Istantiating DataCenter...
MTProto:        	Loading RSA key...
RSA:            	Istantiating \phpseclib\Crypt\RSA...
RSA:            	Loading key...
RSA:            	Computing fingerprint...
RSA:            	Generating BigInteger object for fingerprint...
MTProto:        	Translating tl schemas...
TL:             	Loading TL schemes...
TL:             	Translating objects...
TL:             	Translating methods...
TL:             	Translating objects...
TL:             	Translating methods...
MTProto:        	Switching to DC 2...
DataCenter:     	Connecting to DC 2 (main server, ipv6)...

Any idea?

Bind temporary and the permanent authorization key

I have read here https://core.telegram.org/api/pfs and here https://core.telegram.org/method/auth.bindTempAuthKey for bind temporary and the permanent authorization key
I with respect to understanding the AuthKeyHandler class code wrote the following code

class AuthKeyHandler extends AckHandler
{
    ... 
    ... 
    ... 
    public function bind_temp_auth_key()
    {
        $nonce      = \phpseclib\Crypt\Random::string(16);
        $expires_at = time() + $this->settings['authorization']['auth_key']['expires_in'];

        $data = $this->tl->serialize_obj('bind_auth_key_inner',
            [
                'nonce'             => $nonce,
                'temp_auth_key_id'  => $this->settings['authorization']['temp_auth_key']['id'],
                'perm_auth_key_id'  => $this->settings['authorization']['auth_key']['id'],
                'temp_session_id'   => $this->settings['authorization']['session_id'],
                'expires_at'        => $expires_at,
            ]
        );

        $sha_digest         = sha1($data, true);
        $random_bytes       = \phpseclib\Crypt\Random::string(255 - strlen($data) - strlen($sha_digest));
        $to_encrypt         = $sha_digest.$data.$random_bytes;
        $encrypted_message  = $this->key->encrypt($to_encrypt);

        $result = $this->method_call('auth.bindTempAuthKey',
            [
                'perm_auth_key_id'  => $this->settings['authorization']['auth_key']['id'],
                'nonce'             => $nonce,
                'expires_at'        => $expires_at,
                'encrypted_message' => $encrypted_message,
            ]
        );

        var_dump($result);
    }
}

but the following error

Fatal error: Uncaught exception 'danog\MadelineProto\TL\Exception' with message 'serialize_param: given value isn't numeric'

because $nonce int128 type, but i want long type here

Python factorization not working on windows

It seems that python factorization is not working on windows at all. That's why it takes too long for running.
I tested a very simple python file , just printing a value. It works fine.

But when I run this in cmd:
c:\wamp64\www\ci-telegram-linux\src\danog\MadelineProto>
python getpq.py "1278426847636566097"

Gives me this error:

Traceback (most recent call last):
  File "getpq.py", line 11, in <module>
    pq = prime.primefactors(long(sys.argv[1]))
NameError: name 'long' is not defined

Any idea?

fread(): Length parameter must be greater than 0 in TL problem

Hi, tanx for your great library.
I use code below to get channel's info:

$username = $MadelineProto->contacts->resolveUsername(['username' => "khooroosjangi"]);
$channelInfo = $MadelineProto->channels->getFullChannel(
	['channel' => [
		'_' => 'inputChannel',
		'channel_id' => $username['peer']['channel_id'],
		'access_hash' => $username['chats'][0]['access_hash'],
	]]
);
var_dump($channelInfo);

but the result is different for every channels. For most it works fine but for some like '@khooroosjangi' i will get error:

CallHandler: Calling method (try number 1 for channels.getFullChannel)...
CallHandler: Getting response (try number 1 for channels.getFullChannel)...
CallHandler: An error occurred while calling method channels.getFullChannel: fread(): Length parameter must be greater than 0 in TL on line 270. Recreating connection and retrying to call method...

Please help me. I'm using the last version.

Saving session and using later

Hi.
What I am able to do is this:
Handling authorization, Serializing the session, and then call any method that is available. For example, for sending a message to a peer:

$MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline');
$Updates = $MadelineProto->messages->sendMessage([...]);

Now, I want to know how to store the session in a database and use it later.

NOTE: The output of $MadelineProto is a huge sets of arrays. (I opened in browser's page source, it was about 200,000 lines of arrays or objects).

What I want to do is this:
When a user login to the web app by telegram core api, he wants to send a post in a specific time, without sending manually, so we must save his session in the database.

Error MadelineProto supports only 64 bit systems ATM

I have this error message
Fatal error: Uncaught exception 'danog\MadelineProto\Exception' with message 'MadelineProto supports only 64 bit systems ATM' in W:\domains\telegram.loc\src\danog\MadelineProto\API.php:30 Stack trace: #0 W:\domains\telegram.loc\test.php(4): danog\MadelineProto\API->__construct() #1 {main} thrown in W:\domains\telegram.loc\src\danog\MadelineProto\API.php on line 30
on this test code
require 'vendor/autoload.php'; $MadelineProto = new \danog\MadelineProto\API(); $checkedPhone = $MadelineProto->auth->checkPhone( // auth.checkPhone becomes auth->checkPhone [ 'phone_number' => '3993838383', // Random invalid number, note that there should be no + ] ); $ping = $MadelineProto->ping([3]); // parameter names can be omitted as long as the order specified by the TL scheme is respected $message = "Hey! I'm sending this message with MadelineProto!"; $sentMessage = $MadelineProto->messages->sendMessage(['peer' => '@danogentili', 'message' => $message]); var_dump($sentMessage);

my version php http://prntscr.com/e07d3x

Undefined offset: 0

I have a error with arguments when i call to any method of telegram API that dont have arguments

$MadelineProto->contacts->getContacts();

Error:

  1. in vendor/danog/madelineproto/src/danog/MadelineProto/APIFactory.php at line 31 -
        set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
        $this->API->get_config();
        return $this->API->method_call($this->namespace.$name, is_array($arguments[0]) ? $arguments[0] : []);
        restore_error_handler();
    }
}
  1. at Exception ::ExceptionErrorHandler ('8', 'Undefined offset: 0', '/var/www/ezdesk/vendor/danog/madelineproto/src/danog/MadelineProto/APIFactory.php', '31', array('name' => 'getContacts', 'arguments' => array()))
    in vendor/danog/madelineproto/src/danog/MadelineProto/APIFactory.php at line 31 +

  2. at APIFactory ->__call ('getContacts', array())
    in src/AppBundle/Controller/DefaultController.php at line 61 +

  3. at DefaultController ->listContactsActon (object(Request))

  4. at call_user_func_array (array(object(DefaultController), 'listContactsActon'), array(object(Request)))
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 153 +

  5. at HttpKernel ->handleRaw (object(Request), '1')
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 68 +

  6. at HttpKernel ->handle (object(Request), '1', true)
    in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 169 +

  7. at Kernel ->handle (object(Request))
    in web/app_dev.php at line 28 +

Fix handling of responses (IMPORTANT)

Fix handling of all kinds of responses in MTProtoTools.
I've already added support for a lot of service messages, but there are quite a few left.

Fix mess in PrimeModule

In PrimeModule.php, fix the mess in it, choose one of (the fastest) native php prime factorization function and implement it without biginteger.

New update takes too long to run

Hi. After recent update of MadelineProto there is a problem. It takes very long time to run.
NOTE: Everything is fine in previous versions. Only in recent version occures. (Using linux, ubuntu)

screenshot from 2017-01-31 03 47 25

Error while getting started

Hi. I downloaded the repo and run composer update into it. Then when I want to run this in index.php:

$MadelineProto = new \danog\MadelineProto\API();

I get this error:
Fatal error: Uncaught exception 'danog\MadelineProto\Exception' with message 'MadelineProto supports only 64 bit systems ATM' in C:\xampp\htdocs\MadelineProto-master\src\danog\MadelineProto\API.php:30 Stack trace: #0 C:\xampp\htdocs\MadelineProto-master\index.php(9): danog\MadelineProto\API->__construct() #1 {main} thrown in C:\xampp\htdocs\MadelineProto-master\src\danog\MadelineProto\API.php on line 30

(NOTE: I'am on windows 10, 64 bit)

Working threads

First, thank you for this awesome project ! I'll look forward to contribute very soon :-).
That said, I would like to suggest using a library such as ReactPHP, Icicle.io or equivalent in order to permit assynchronous, non-blocking I/O. I think that, since the project its still in the beginning, this change wouldn't impact too much. I can try to work this into the code if necessary.

json_encode does not work on $MadelineProto

Hi there, I try to get users contacts photos using upload_getfile method and it works correctly in a normal way but it needs many deserializing of $MadelineProto for each contact so we try to encode it after first initialization and call downloads methods using ajax but echo json_encode($MadelineProto); returns ''.
Thanks for your great library.

send inline URL

hi
sending inline URL not work ==> it is not show link ==> show as a simple text
also in Markdown not create link
inline URL

$MadelineProto->messages->sendMessage(['peer' => '@xxx', 'message' =>'[site man](http://www.mohsendavari.ir/)' , 'parse_mode' =>'Markdown']);

An error occurred while calling method auth.bindTempAuthKey

please see the response from server. The response is always -1.
"seq_no" => 1
"response" => -1
"content" => array:2 [▼
"method" => "auth.bindTempAuthKey"
"args" => array:4 [▼
"perm_auth_key_id" => -3762483724584418177
"nonce" => 6373879830466581345
"expires_at" => 1513558242
"encrypted_message" => b"\x7F\x04§¬³°╚╦e▄Vç╩ &r"╣Úâ®ö┤*!╝o\x068LA¿¸7┘YÙz¾? ì█\x0E~\x06&Ðþ²G4õ\x183Î/ê╔:²M\x15Yƒûeª\x1FB\f&ëv▄\x0Eò\x07z¤ÎrÊ\x11bIá\x1EÈ\x18¥\rF¥úÓ╦ÎS\r´ÙL"
]
]
"ack" => true

Unrecognized flag type (Bool)

PHP Fatal error: Uncaught danog\MadelineProto\TL\Exception: Unrecognized flag type (Bool) in .../MadelineProto/src/danog/MadelineProto/TL/TL.php:96

Adding "case 'Bool':" fixed the issue, but I'm not sure if it should be added.

An error occurred while calling method req_pq: Given message id (6346469674134935553) is too new

Hi,
I got following error when executing testing.php. Pls let me know whats causing this?

MTProto: Connecting to server...
MTProto: Loading RSA key...
MTProto: Initializing StructTools...
MTProto: Translating tl schemas...
MTProto: Generating permanent authorization key...
AuthKeyHandler: Requesting pq
CallHandler: Getting response (try number 1 for req_pq)...
CallHandler: An error occurred while calling method req_pq: Given message id (6346469667123256321) is too new. in MsgIdHandler on line 26. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for req_pq)...
CallHandler: An error occurred while calling method req_pq: Given message id (6346469668922249217) is too new. in MsgIdHandler on line 26. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for req_pq)...
CallHandler: An error occurred while calling method req_pq: Given message id (6346469670560631809) is too new. in MsgIdHandler on line 26. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for req_pq)...
CallHandler: An error occurred while calling method req_pq: Given message id (6346469672048287745) is too new. in MsgIdHandler on line 26. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for req_pq)...
CallHandler: An error occurred while calling method req_pq: Given message id (6346469674134935553) is too new. in MsgIdHandler on line 26. Recreating connection and retrying to call method...
PHP Fatal error: Uncaught exception 'danog\MadelineProto\MTProtoTools\Exception' with message 'An error occurred while calling method req_pq.' in /var/www/html/telegram/MadelineProto/src/danog/MadelineProto/MTProtoTools/CallHandler.php:69
Stack trace:
#0 /var/www/html/telegram/MadelineProto/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php(50): danog\MadelineProto\MTProtoTools\CallHandler->method_call('req_pq', Array)
#1 /var/www/html/telegram/MadelineProto/src/danog/MadelineProto/MTProto.php(137): danog\MadelineProto\MTProtoTools\AuthKeyHandler->create_auth_key(-1)
#2 /var/www/html/telegram/MadelineProto/src/danog/MadelineProto/API.php(22): danog\MadelineProto\MTProto->__construct(Array)
#3 /var/www/html/telegram/MadelineProto/testing.php(11): danog\MadelineProto\API->__construct(Array)
#4 {main}

thrown in /var/www/html/telegram/MadelineProto/src/danog/MadelineProto/MTProtoTools/CallHandler.php on line 69

error when executing testing.php

Hi,
I got following error when executing testing.php. Pls let me know whats causing this?

#!/usr/bin/env php
MTProto: Connecting to server...
MTProto: Loading RSA key...
MTProto: Initializing StructTools...
MTProto: Translating tl schemas...
MTProto: Generating permanent authorization key...
AuthKeyHandler: Requesting pq
CallHandler: Getting response (try number 1 for req_pq)...
PrimeModule: Trying to use the python factorization module
AuthKeyHandler: Factorization 3021788980811230517 = 1522725973 * 1984460129
AuthKeyHandler: Starting Diffie Hellman key exchange
CallHandler: Getting response (try number 1 for req_DH_params)...
AuthKeyHandler: Server-client time delta = -1.0 s
AuthKeyHandler: Executing dh_prime checks...
CallHandler: Getting response (try number 1 for set_client_DH_params)...
AuthKeyHandler: Diffie Hellman key exchange processed successfully
AuthKeyHandler: Auth key generated
MTProto: Generating temporary authorization key...
AuthKeyHandler: Requesting pq
CallHandler: Getting response (try number 1 for req_pq)...
PrimeModule: Trying to use the python factorization module
AuthKeyHandler: Factorization 2587613226443475283 = 1426789123 * 1813591921
AuthKeyHandler: Starting Diffie Hellman key exchange
CallHandler: Getting response (try number 1 for req_DH_params)...
AuthKeyHandler: Server-client time delta = 0.0 s
AuthKeyHandler: Executing dh_prime checks...
CallHandler: Getting response (try number 1 for set_client_DH_params)...
AuthKeyHandler: Diffie Hellman key exchange processed successfully
AuthKeyHandler: Auth key generated
MTProto: Writing client info...
CallHandler: Getting response (try number 1 for invokeWithLayer)...
ResponseHandler: Received container.
ResponseHandler: array (
0 =>
array (
'' => 'message',
'msg_id' => 6347854607584969729,
'seqno' => 1,
'bytes' => 28,
'body' =>
array (
'
' => 'new_session_created',
'first_msg_id' => 6347854602840027804,
'unique_id' => 5002409984457564783,
'server_salt' => 3196422576473308380,
),
),
1 =>
array (
'' => 'message',
'msg_id' => 6347854607585020929,
'seqno' => 2,
'bytes' => 20,
'body' =>
array (
'
' => 'msgs_ack',
'msg_ids' =>
array (
0 => 6347854602840027804,
),
),
),
)
ResponseHandler: new session created
ResponseHandler: array (
'' => 'new_session_created',
'first_msg_id' => 6347854602840027804,
'unique_id' => 5002409984457564783,
'server_salt' => 3196422576473308380,
)
CallHandler: Getting response (try number 2 for invokeWithLayer)...
MTProto: Current dc is 2, nearest dc is 2 in ID.
CallHandler: Getting response (try number 1 for auth.bindTempAuthKey)...
CallHandler: An error occurred while calling method auth.bindTempAuthKey: Received bad_msg_notification array (
'
' => 'bad_msg_notification',
'bad_msg_id' => 0,
'bad_msg_seqno' => 3,
'error_code' => 16,
) in ResponseHandler on line 44. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for auth.bindTempAuthKey)...
CallHandler: An error occurred while calling method auth.bindTempAuthKey: Received bad_msg_notification array (
'' => 'bad_msg_notification',
'bad_msg_id' => 0,
'bad_msg_seqno' => 5,
'error_code' => 16,
) in ResponseHandler on line 44. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for auth.bindTempAuthKey)...
CallHandler: An error occurred while calling method auth.bindTempAuthKey: Received bad_msg_notification array (
'
' => 'bad_msg_notification',
'bad_msg_id' => 0,
'bad_msg_seqno' => 7,
'error_code' => 16,
) in ResponseHandler on line 44. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for auth.bindTempAuthKey)...
CallHandler: An error occurred while calling method auth.bindTempAuthKey: Received bad_msg_notification array (
'' => 'bad_msg_notification',
'bad_msg_id' => 0,
'bad_msg_seqno' => 9,
'error_code' => 16,
) in ResponseHandler on line 44. Recreating connection and retrying to call method...
CallHandler: Getting response (try number 1 for auth.bindTempAuthKey)...
CallHandler: An error occurred while calling method auth.bindTempAuthKey: Received bad_msg_notification array (
'
' => 'bad_msg_notification',
'bad_msg_id' => 0,
'bad_msg_seqno' => 11,
'error_code' => 16,
) in ResponseHandler on line 44. Recreating connection and retrying to call method...

AuthKeyHandler error

executing testing.php

AuthKeyHandler: Executing set_client_DH_params...
CallHandler: Calling method (try number 1 for set_client_DH_params)...
AuthKeyHandler: An RPCErrorException occurred while generating the authorization key: -404 Retrying (try number 5)...
PHP Fatal error: Uncaught exception 'danog\MadelineProto\Exception' with message 'Auth Failed' in /home/vdesktop/MadelineProto/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php:480
Stack trace:
#0 /home/vdesktop/MadelineProto/src/danog/MadelineProto/MTProto.php(285): danog\MadelineProto\MTProto->create_auth_key(-1)
#1 /home/vdesktop/MadelineProto/src/danog/MadelineProto/MTProto.php(253): danog\MadelineProto\MTProto->init_authorization()
#2 /home/vdesktop/MadelineProto/src/danog/MadelineProto/MTProto.php(56): danog\MadelineProto\MTProto->switch_dc(2, true)
#3 /home/vdesktop/MadelineProto/src/danog/MadelineProto/API.php(34): danog\MadelineProto\MTProto->__construct(Array)
#4 /home/vdesktop/MadelineProto/tests/testing.php(33): danog\MadelineProto\API->__construct(Array)
#5 {main}
thrown in /home/vdesktop/MadelineProto/src/danog/MadelineProto/MTProtoTools/AuthKeyHandler.php on line 480

Can not able to send code to telegram

Hi.

I run testing.php , set $number manually to my own phone number. Then telegram sends me the code. The result of running is this: (last parts)

...
Login:          	Code sent successfully! Once you receive the code you should use the complete_phone_login function.
testing:        	array (
  '_' => 'auth.sentCode',
  'phone_registered' => true,
  'type' => 
  array (
    '_' => 'auth.sentCodeTypeApp',
    'length' => 5,
  ),
  'phone_code_hash' => 'some hash code here',
  'next_type' => 
  array (
    '_' => 'auth.codeTypeSms',
  ),
  'phone_number' => '+989380597197',
)
Enter the code you received: 

Then nothing happen.

First : In testing.php there a function called complete_phone_login. The parameter of this function is $code. But code is sent by telegram, it must be passed manually. What is $code?

Second : I call complete_phone_login function in a separate file, so when telegram sends me the code, I pass it to this function manually, then run it. But again no results. Any idea?

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.