diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php index a17732c8..d6f3424d 100644 --- a/src/danog/MadelineProto/API.php +++ b/src/danog/MadelineProto/API.php @@ -15,14 +15,15 @@ namespace danog\MadelineProto; class API extends Tools { public $session; - + public $settings; public function __construct($params = []) { set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']); $this->session = new MTProto($params); + $this->settings = &$this->session->settings; \danog\MadelineProto\Logger::log('Running APIFactory...'); - foreach ($this->session->tl->method_name_namespaced as $method) { + foreach ($this->session->tl->method_names_namespaced as $method) { if (isset($method[1])) { if (!isset($this->{$method[0]})) { $this->{$method[0]} = new APIFactory($method[0], $this->session); @@ -32,10 +33,10 @@ class API extends Tools } \danog\MadelineProto\Logger::log('Ping...'); - $ping = $this->ping(3); + $ping = $this->ping([3]); \danog\MadelineProto\Logger::log('Pong: '.$ping['ping_id']); \danog\MadelineProto\Logger::log('Getting future salts...'); - $future_salts = $this->get_future_salts(3); + $future_salts = $this->get_future_salts([3]); \danog\MadelineProto\Logger::log('MadelineProto is ready!'); } @@ -47,9 +48,9 @@ class API extends Tools public function __call($name, $arguments) { - if (!in_array($name, $this->session->tl->method_name_namespaced)) { + if (!in_array($name, $this->session->tl->method_names)) { throw new Exception("The called method doesn't exist!"); } - return $this->session->method_call($name, $arguments); + return $this->session->method_call($name, $arguments[0]); } } diff --git a/src/danog/MadelineProto/APIFactory.php b/src/danog/MadelineProto/APIFactory.php index 66d9eef6..2f8cf984 100644 --- a/src/danog/MadelineProto/APIFactory.php +++ b/src/danog/MadelineProto/APIFactory.php @@ -28,7 +28,7 @@ class APIFactory if (!in_array($name, $this->allowed_methods)) { throw new Exception("The called method doesn't exist!"); } - return $this->session->method_call($this->namespace.'.'.$name, $arguments); + return $this->session->method_call($this->namespace.'.'.$name, $arguments[0]); } } \ No newline at end of file diff --git a/src/danog/MadelineProto/MTProto.php b/src/danog/MadelineProto/MTProto.php index 33181a98..133c4b6b 100644 --- a/src/danog/MadelineProto/MTProto.php +++ b/src/danog/MadelineProto/MTProto.php @@ -125,7 +125,6 @@ Slv8kg9qv1m6XHVQY3PnEw+QQtqSIXklHwIDAQAB $this->future_salts = []; $this->switch_dc($this->settings['connection_settings']['default_dc'], true); - } public function setup_logger() diff --git a/src/danog/MadelineProto/TL/TL.php b/src/danog/MadelineProto/TL/TL.php index 420f9788..9f059047 100644 --- a/src/danog/MadelineProto/TL/TL.php +++ b/src/danog/MadelineProto/TL/TL.php @@ -45,7 +45,8 @@ class TL extends \danog\MadelineProto\Tools $z = new \danog\MadelineProto\TL\TLMethod($elem); $this->method_id[$z->id] = $z; $this->method_name[$z->method] = $z; - $this->method_name_namespaced[$z->method] = explode('.', $z->method); + $this->method_names[$z->method] = $z->method; + $this->method_names_namespaced[$z->method] = explode('.', $z->method); } } diff --git a/testing.php b/testing.php index 95e2d3ca..85ada4d9 100755 --- a/testing.php +++ b/testing.php @@ -21,9 +21,9 @@ if (file_exists('number.php')) { [ 'phone_number' => $number, 'sms_type' => 5, - 'api_id' => $this->settings['app_info']['api_id'], - 'api_hash' => $this->settings['app_info']['api_hash'], - 'lang_code' => $this->settings['app_info']['lang_code'], + 'api_id' => $MadelineProto->settings['app_info']['api_id'], + 'api_hash' => $MadelineProto->settings['app_info']['api_hash'], + 'lang_code' => $MadelineProto->settings['app_info']['lang_code'], ] ); var_dump($sendCode);