Download the PHP package adamculp/api-consumer without Composer

On this page you can find all versions of the php package adamculp/api-consumer. 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 api-consumer

CircleCI

About

Simple PHP 7.3 class to consume an API through GET using Curl. (created to consume APIs, and could be used for other things) Methods build API URL params, connection url, and parse expected JSON response.

In the future I intend to add the possibility of an XML return as well, and may even break out the limited Curl functionality to another class, or simply use Guzzle.

Requirements

Requires PHP version 7.3 if namespaces are desired.

Installation

This class can be used directly from a GIT clone:

git clone https://github.com/adamculp/api-consumer.git

You could also download the ApiConsumer package and move the directory to a desired location where your scripts can then call it.

Alternatively you could simply copy the ApiConsumer.php file to a desired location and call it that way as well.

Non-Composer Usage

This class was written using namespaces available via PHP 5.3+, and if left unchanged would be used in the following manner: NOTE: This class contains information needed to utilize a certain Mashery API at Active.com, but you can change the URL and params as needed for other APIs that return JSON.

require_once 'path/to/src/ApiConsumer/Consumer.php';
use ApiConsumer\Consumer;

$apiConsumer = new Consumer();
$url = 'http://api.amp.active.com/search?';

$apiConsumer->setUrl($url);

$meta = 'meta:channel=Running+meta:startDate:daterange:today..' . date('Y-m-d', strtotime('next month'));
$params = array(
                'k' => 'ultra+marathon',
                'v' => 'json',
                'l' => 'Florida',
                'r' => '25',
                's' => 'date_asc',
                'api_key' => '{Add API Key Here}',
                'm' => $meta
            );

$options = array(); // key=>value pairs can be added here to alter the curl call

$apiConsumer->setParams($params);

$apiConsumer->setOptions($options);

$apiConsumer->setResponseType('json');
$apiConsumer->setCallType('get');

$result = $apiConsumer->doApiCall();

Composer Usage

After either installing Composer using one of the two methods shown at http://getcomposer.org the composer.json would look like:

{
    "require": {
        "adamculp/api-consumer": "dev-master"
    }
}

Then you'll need to alter the require_once in the sample above to point to the Composer autoload instead of to the class itself.

require_once 'vendor/autoload.php'; // to include the composer autoloader

From there you can use the $result array as you see fit.

Please use the /api-consumer/index.php as a working example (minus the API key) of how the class can be included and used.


All versions of api-consumer with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
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 adamculp/api-consumer contains the following files

Loading the files please wait ....