2017 © Pedro Peláez
 

library spiget-api

A PHP implementation of the Spiget.org API

image

gamepanelio/spiget-api

A PHP implementation of the Spiget.org API

  • Saturday, September 9, 2017
  • by gamepanelio
  • Repository
  • 2 Watchers
  • 3 Stars
  • 10 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 11 % Grown

The README.md

Spiget.org PHP API Client

This library is a basic PHP implementation of the Spiget.org API., (*1)

Installation

This library uses the HTTPlug HTTP client abstraction library - meaning you can use your favourite HTTP library with it!, (*2)

For a quick and easy way to use this library in your project, via composer, run the following:, (*3)

  composer require php-http/curl-client guzzlehttp/psr7 php-http/message gamepanelio/spiget-api

There are also lots of different libraries that you can use with HTTPlug. To see how to use different libraries please refer to the HTTPlug documentation., (*4)

Usage

Simply instantiate a new Spiget() class, and use the methods it provides:, (*5)

<?php

use GamePanelio\SpigetApi\Spiget;

$spiget = new Spiget("My_cool_user_agent/1.0");

$response = $spiget->getResourceSearch(
    'search_param',
    [
        /* ... additional parameters ... */
    ]
);

Return Data

Each method returns a PSR-7 Response., (*6)

$response = $spiget->getResourcesList();

// To get the response data
var_dump($spiget->getResponseBodyFromJson($response));
// or
var_dump(json_decode($response->getBody(), true));


// To get the page count, etc
var_dump($response->getHeaderLine('X-Page-Count'));

API Errors and Exceptions

Any response which is not successful (HTTP code =300) will throw a ApiCommunicationException., (*7)

If you are using a library that throws PSR-7 errors for such responses (for example, Guzzle), they will be wrapped and you can access the PSR-7 exception via the ->getPrevious() method., (*8)

Naming Conventions

Each method provided by the Spiget class has a naming convention of the following format:, (*9)

$spiget->[method-related-term][action]()

License

This library is licensed under the MIT license. See the LICENSE file for more info., (*10)

The Versions

09/09 2017

dev-master

9999999-dev

A PHP implementation of the Spiget.org API

  Sources   Download

MIT

The Requires

 

The Development Requires

by CraftSRV Ltd.

09/09 2017

0.2.0

0.2.0.0

A PHP implementation of the Spiget.org API

  Sources   Download

MIT

The Requires

 

The Development Requires

by CraftSRV Ltd.

15/08 2017

0.1.1

0.1.1.0

A PHP implementation of the Spiget.org API

  Sources   Download

MIT

The Requires

 

The Development Requires

by CraftSRV Ltd.

02/08 2017

0.1.0

0.1.0.0

A PHP implementation of the Spiget.org API

  Sources   Download

MIT

The Requires

 

The Development Requires

by CraftSRV Ltd.