From a17ccba895f5e980947264f929611e157aa7c35c Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Wed, 26 Feb 2020 15:46:13 +0100 Subject: [PATCH] Fix docs --- docs/botLogin.md | 2 +- docs/complete2FALogin.md | 4 +++- docs/completePhoneLogin.md | 2 +- docs/completeSignup.md | 2 +- docs/docs/FILES.md | 28 +++++++++++++++++----------- docs/docs/SETTINGS.md | 4 ++-- docs/phoneLogin.md | 2 +- 7 files changed, 26 insertions(+), 18 deletions(-) diff --git a/docs/botLogin.md b/docs/botLogin.md index 6ec6d75e..5575376d 100644 --- a/docs/botLogin.md +++ b/docs/botLogin.md @@ -12,7 +12,7 @@ redirect_from: /bot_login.html |----------|---------------| |token| A string with the bot token| -### Return type: [auth.Authorization](API_docs/types/auth_Authorization.md) +### Return type: [auth.Authorization](API_docs/types/auth.Authorization.md) ### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)): diff --git a/docs/complete2FALogin.md b/docs/complete2FALogin.md index d464f639..61fad51e 100644 --- a/docs/complete2FALogin.md +++ b/docs/complete2FALogin.md @@ -2,6 +2,8 @@ title: complete2falogin description: complete2falogin parameters, return type and example redirect_from: /complete_2fa_login.html +redirect_from: /complete2falogin.html +redirect_from: /complete2FAlogin.html --- ## Method: complete2falogin @@ -12,7 +14,7 @@ redirect_from: /complete_2fa_login.html |----------|---------------| |password| A string with the password| -### Return type: [auth.Authorization](API_docs/types/auth_Authorization.md) +### Return type: [auth.Authorization](API_docs/types/auth.Authorization.md) ### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)): diff --git a/docs/completePhoneLogin.md b/docs/completePhoneLogin.md index 9eb4110c..0a271dbd 100644 --- a/docs/completePhoneLogin.md +++ b/docs/completePhoneLogin.md @@ -12,7 +12,7 @@ redirect_from: /complete_phone_login.html |----------|---------------| |code| A string with the phone code| -### Return type: [auth.Authorization](API_docs/types/auth_Authorization.md) or [account.Password](http://docs.madelineproto.xyz/API_docs/types/account_Password.html) or `['_' => 'account.needSignup']` +### Return type: [auth.Authorization](API_docs/types/auth.Authorization.md) or [account.Password](http://docs.madelineproto.xyz/API_docs/types/account_Password.html) or `['_' => 'account.needSignup']` You must then use [complete2falogin](complete2FALogin.md) or [completeSignup](completeSignup.md) to login or signup, or simply start using `$MadelineProto` if the result is a `auth.Authorization` object. diff --git a/docs/completeSignup.md b/docs/completeSignup.md index 804bc9b2..52a7df51 100644 --- a/docs/completeSignup.md +++ b/docs/completeSignup.md @@ -13,7 +13,7 @@ redirect_from: /complete_signup.html |first_name| A string with the first name| |last_name| Optional, string with the last name| -### Return type: [auth.Authorization](API_docs/types/auth_Authorization.md) +### Return type: [auth.Authorization](API_docs/types/auth.Authorization.md) ### Example ([now fully async!](https://docs.madelineproto.xyz/docs/ASYNC.html)): diff --git a/docs/docs/FILES.md b/docs/docs/FILES.md index 4e80db2c..bc395ecd 100644 --- a/docs/docs/FILES.md +++ b/docs/docs/FILES.md @@ -373,27 +373,33 @@ The callable should return the number of written bytes. `$MessageMedia`can be either a [Message](https://docs.madelineproto.xyz/API_docs/types/Message.html), an [Update](https://docs.madelineproto.xyz/API_docs/types/Update.html), a [MessageMedia](https://docs.madelineproto.xyz/API_docs/types/MessageMedia.html) object, or a bot API file ID. -### Download to browser with streams +### Download to http-server ```php -$info = yield $MadelineProto->getDownloadInfo($MessageMedia); -header('Content-Length: '.$info['size']); -header('Content-Type: '.$info['mime']); - -$stream = fopen('php://output', 'w'); -yield $MadelineProto->downloadToStream($MessageMedia, $stream, $cb, $offset, $endoffset); +yield $MadelineProto->downloadToResponse($MessageMedia, $request, $cb); ``` -This downloads the given file to the browser, sending also information about the file's type and size. +This downloads the given file, replying to the specified [async http-server](https://amphp.org/http-server) request. +Automatically supports HEAD requests and content-ranges for parallel and resumed downloads. `$MessageMedia` can be either a [Message](https://docs.madelineproto.xyz/API_docs/types/Message.html), an [Update](https://docs.madelineproto.xyz/API_docs/types/Update.html), a [MessageMedia](https://docs.madelineproto.xyz/API_docs/types/MessageMedia.html) object, or a bot API file ID. -`$stream` must be a writeable stream +`$request` is the [Request](https://amphp.org/http-server/classes/request) object returned by [http-server](https://amphp.org/http-server). `$cb` is an optional parameter can be a callback for download progress, but it shouldn't be used, the new [FileCallback](#getting-progress) should be used instead -`$offset` is an optional parameter that specifies the byte from which to start downloading -`$endoffset` is an optional parameter that specifies the byte where to stop downloading (non-inclusive) + +### Download to browser +```php +yield $MadelineProto->downloadToBrowser($MessageMedia, $cb); +``` + +This downloads the given file to the browser, sending also information about the file's type and size. +Automatically supports HEAD requests and content-ranges for parallel and resumed downloads. + +`$MessageMedia` can be either a [Message](https://docs.madelineproto.xyz/API_docs/types/Message.html), an [Update](https://docs.madelineproto.xyz/API_docs/types/Update.html), a [MessageMedia](https://docs.madelineproto.xyz/API_docs/types/MessageMedia.html) object, or a bot API file ID. + +`$cb` is an optional parameter can be a callback for download progress, but it shouldn't be used, the new [FileCallback](#getting-progress) should be used instead ## Getting progress diff --git a/docs/docs/SETTINGS.md b/docs/docs/SETTINGS.md index 7fb1f476..b94edf07 100644 --- a/docs/docs/SETTINGS.md +++ b/docs/docs/SETTINGS.md @@ -358,7 +358,7 @@ Description: maximum number of allowed MTProto messages in the outgoing message ### `$settings['msg_array_limit']['call_queue']` Default: 200 -Description: maximum number of allowed MTProto messages in any [call queue](USING_METHOD.html#call-queues) +Description: maximum number of allowed MTProto messages in any [call queue](USING_METHODS.html#call-queues)
@@ -439,4 +439,4 @@ The settings array can be accessed and modified in the instantiated class by acc $MadelineProto->settings['updates']['handle_updates'] = true; // reenable update fetching ``` -Next section \ No newline at end of file +Next section diff --git a/docs/phoneLogin.md b/docs/phoneLogin.md index 76d0b03e..d1e51267 100644 --- a/docs/phoneLogin.md +++ b/docs/phoneLogin.md @@ -12,7 +12,7 @@ redirect_from: /phone_login.html |----------|---------------| |number| A string with the phone number, including the country code| -### Return type: [auth.SentCode](API_docs/types/auth_SentCode.md) +### Return type: [auth.SentCode](API_docs/types/auth.SentCode.md) You must then use [completePhoneLogin](completePhoneLogin.md)