mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Fix syntax in VKAPI readme
This commit is contained in:
parent
e18a661507
commit
8b86b35bcc
1 changed files with 5 additions and 5 deletions
|
@ -5,7 +5,7 @@ This directory contains VK api handlers, structures and relared exceptions. It i
|
|||
|
||||
h2. Implementing API methods
|
||||
|
||||
VK API methods have names like this: %example.test%. To implement a method like this you will need to create a class %Example% in the Handlers subdirectory. This class **must** extend VKAPIHandler and be final.
|
||||
VK API methods have names like this: @example.test@. To implement a method like this you will need to create a class @Example@ in the Handlers subdirectory. This class **must** extend VKAPIHandler and be final.
|
||||
Next step is to create %test% method. It **must** have a type hint that is not %void%. Everything else is fine, the return value of method will be authomatically converted to JSON and sent back to client.
|
||||
|
||||
h3. Parameters
|
||||
|
@ -15,14 +15,14 @@ If parameter is not passed by client then router will pass default value to argu
|
|||
|
||||
h3. Returning errors
|
||||
|
||||
To return an error, call %fail% method like this: %$this->fail(5, "error")% (first argument is error code and second is error message). You can also throw the exception manually: %throw new APIErrorException("error", 5)% (class: openvk.VKAPI.Exceptions.APIErrorException).
|
||||
To return an error, call %fail% method like this: @$this->fail(5, "error")@ (first argument is error code and second is error message). You can also throw the exception manually: @throw new APIErrorException("error", 5)@ (class: openvk.VKAPI.Exceptions.APIErrorException).
|
||||
If you throw any exception that does not inherit APIErrorException then API will return error №1 (unknown error) to client.
|
||||
|
||||
h3. Refering to user
|
||||
|
||||
To get user use %getUser% method: %$this->getUser()%. Keep in mind it will return NULL if user is undefined (no access_token passed or it is invalid/expired or roaming authentification failed).
|
||||
If you need to check whether user is defined use %userAuthorized%. This method returns true if user is present and false if not.
|
||||
If your method can't work without user context call %requireUser% and it will automatically return unauthorized error.
|
||||
To get user use @getUser@ method: @$this->getUser()@. Keep in mind it will return NULL if user is undefined (no access_token passed or it is invalid/expired or roaming authentification failed).
|
||||
If you need to check whether user is defined use @userAuthorized@. This method returns true if user is present and false if not.
|
||||
If your method can't work without user context call @requireUser@ and it will automatically return unauthorized error.
|
||||
|
||||
h3. Working with data
|
||||
|
||||
|
|
Loading…
Reference in a new issue