Download the PHP package adiafora/php-api-client without Composer

On this page you can find all versions of the php package adiafora/php-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-api-client

php-api-client

This package makes it very easy to access any API using both GET and POST requests. You can also send headers and parameters.

Installation

Run:

Configurations

You can set parameters for curl using global constants.

SET_CURLOPT_CONNECTTIMEOUT - The number of seconds to wait while trying to connect. Use 0 to wait indefinitely. Default is 10. SET_CURLOPT_TIMEOUT - The maximum number of seconds to allow cURL functions to execute. Default is 10.

Usage

You must create a class that extends the Adiafora\ApiClient\AbstractApiClient abstract class. And define the methods:

getHeaders() - returns an array of headers.

getUrl() - returns a string, the API url.

And in your project, you must refer to this class, which extends the Adiafora\ApiClient\AbstractApiClient.

When accessing your class, you can pass the GET or POST request type (by default GET) and an array of request parameters, if any, to the constructor method. if you execute a GET request without parameters, you don't need to pass anything to the constructor method.

To make a request to the API, call the send() method:

The method returns an object of class Adiafora\ApiClient\ApiResponse that contains these methods:

code() - return code of response.

response() - return response from the API decoded using json_decode(). Because most APIs return a response in json format. If you want to get the answer as it is, then use the dirty() method.

dirty() - return the answer as it is without transformations.

error() - return curl_error() for the curl.

errno() - return curl_errno() for the curl.

requestParameters() - return parameters of request.

requestUrl() - return url of request.

requestHeaders() - return headers of request.

totalTime() - return total transaction time in seconds for last transfer.

Real example

For example, we need to connect to the Yandex.Webmaster API.

For more information, see the API documentation https://yandex.com/dev/webmaster/doc/dg/concepts/About.html/

We are creating a class WebmasterApiClient

We have implemented 2 required methods getHeaders() and getUrl(). Everything else, including the implementation of the constructor method, is only necessary for implementing a specific API.

Now we want to get a list of all hosts. There is nothing easier! Just:

Or getting the history of SQI changes using the parameters:

License

The MIT License (MIT). Please see License File for more information.


All versions of php-api-client with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
ext-curl Version *
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package adiafora/php-api-client contains the following files

Loading the files please wait ....