Download the PHP package reset-button/a-parser-php-client without Composer
On this page you can find all versions of the php package reset-button/a-parser-php-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reset-button/a-parser-php-client
More information about reset-button/a-parser-php-client
Files in reset-button/a-parser-php-client
Package a-parser-php-client
Short Description For this package there is no description available.
License
Informations about the package a-parser-php-client
A-Aparser PHP API
This A-parser PHP API library provides convenient access to the A-Parser HTTP API.
Requirements
- php >= 8.1
- guzzlehttp/guzzle >= 7.0
Installation
Quickstart
Usage
Basic Action Usage
Define an A-parser instance, passing full URL to API endpoint and password
Instantiate an action using the appropriate action class, as outlined in the official documentation
Run the action by calling runAction
method
Using Parser class in Actions
All actions that accept parser name and config as parameter, accept a Parser
instance instead (addTask, oneRequest, bulkRequest, getParserPreset, getParserInfo)
Parser
class contains all logic, related to used parser in API methods, that used it
In minimal approach you need only to create Parser
instance without any configuration and pass it to corresponding method
You can configure parser with options, overrides, etc before passing it to action by calling corresponding methods
Or you can set full configuration at once using a corresponding method, this is useful when copy pasting from API request
Note, that parser configuration has no effect in
getParserPreset
andgetParserInfo
actions.
Configuring Actions
All action required parameters are configured via constructor, and optional are set using builder pattern with corresponding parameters from the documentations with "set" prefix, for example
Configuring addTask
action
This method is differs from others methods, it can be instantiated via passing at least one parser or passing a previously saved preset, this two methods are implemented via named constructor
Also, addTask
action is a most complex action in API, so many setters for are not implemented and you should use setDataValue
from Action Direct Methods to set parameters
Setting queries source
You should pass queries when creating action, no matter the source. And then change queries source using setQueriesFrom...
methods, default behavior is from text.
Action Direct Methods
You can read any configuration option using getDataValue
helper, if this option is not exists - null will returned
You can directly set/overwrite any configuration option using setDataValue
helper. Use with caution.
You can get all full configuration options using getData
helper.
Aparser methods
Instantiate A-parser instance by passing URL to API endpoint and password
Prepare actions and run it by calling runAction
method
runActionwill return
datasection from A-parser success response payload or throw a
AparserApiException` if A-parser responds with error
You can get JSON string from passed action using getJsonString
helper.
At last, you can just copy JSON query from A-parser and send it via API directly even ignoring previously passed password
License
This package is open-sourced software licensed under the MIT license.