Download the PHP package matthillman/swgoh-help without Composer

On this page you can find all versions of the php package matthillman/swgoh-help. 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 swgoh-help

API wrapper for swgoh.help

Introduction

Laravel wrapper for the swgoh.help API.

Requires Laravel 5.4 or greater

Installation

Setup

Credentials

The wrapper looks for credentials stored in Laravel's "services" configuration under the "swgoh_help" key. You must include your username and password; you can optionally include the client_id and client_secret, but given how swogh.help is set up, this is not needed.

Example configuration:

config/services.php:

.env file:

Usage

The wrapper provides four shortcut calls that wrap common projections around the actual API call as well as a generic function that can be used to craft any possible API query.

Quick start

Calling the API is as simple as invoking the helper function followed by the query you want to make:

Convenience queries

Note that all queries return an instance of Illuminate\Support\Collection

getPlayer($allyCode, $projection = [])

Used to get a player's profile information (by default without their roster, though this can be overridden). Calls the /player endpoint with the following payload:

getUnits($allyCode, $mods = false, $projection = [])

Used to retrieve a player's unit list, optionally including mods. This calls the /units endpoint with with following payload:

getMods($allyCode)

Used to retrieve a collection of player's mods, keyed by unit. This calls the /units endpoint and is equivalent to calling this endpoint with projection: { mods: 1 }. This is a shortcut for calling getUnits() with the following projection override:

getGuild($allyCode, Callable $memberCallback, $fullRoster = false, $mods = false, $projection = [])

Used to retrieve information about a guild and calls into the /guild endpoint. As this is the most complicated helper, let's expand upon it.

If you are including rosters, it is very likely that this call would produce a return that puts PHP's json decoder over the default PHP memory limit. To avoid this, this call will process

The full payload passed to the endpoint is the following:

getUnitData($match = [], $projection = [])

Retrieves the unit list by calling the /data endpoint. Uses the following projection:

function getZetaData()

This function makes two calls to the /data endpoint to get a list of all zetas in the the game. The query correlates a call to the skillList with abilityList. The return will be in the following structure:

Main query

function callAPI($api, $payload, Callable $memberCallback = null)

This is the main function of the wrapper. You can use this to craft any payload needed for any API endpoint.

Creation and options

There are two options to get an API wrapper to work with, either by using the helper function or just creating a new instance.

The language key and enum are properties on the API class itself. They default to eng_us and true, respectively. If you are keeping a reference to the API wrapper then you can set them before querying, If you are using the helper function (or just want to), then there are two helper calls that can be chained before the query calls. (Since enums are true by defualt, the chaining helper is only for diabling them)

The following are equivalent:

Parser classes

In case an API wrapper wasn't enough, also included are three additional wrappers! 🎉

Each parser class takes a constructor argument so that it knows what to work on, but does not do any work until you call scrape().

ProfileParser

Parser the results of the getPlayer() call. It maps the player stats into a collection and transforms the updated timestamp into a proper Carbon date.

Example

ModsParser

Parses the results of the getMods() call. It maps the player mod data into an array of items (mods) with the following format:

Note the use of the ModSet and ModSlot enums.

Example

GuildParser

This class wraps the getGuild() call. However, instead of taking an ally code, this class takes the ID number from the guild's url on swogh.gg.

Yes, that is correct, the ID from the guild's swogh.gg url, which is completely unrelated to the swgoh.help API.

But why?

Because, I wanted to make something that would query information for any guild. The swgoh.help API requires an ally code for any member in the guild. Imagine this scenario:

  1. System: Hey, input the ally code from any user in the guild!
  2. User: Hmmm, let me go search swgoh.gg and find one
  3. User: google "guild name swgoh"
  4. User: click swgoh.gg link
  5. Smart user: click any member, note ally code in the url
  6. less smart user: click each member to find one with an ally code listed
  7. All users: return, enter the ally code they found

swgoh.gg is the public directory for this information; people will have an easier time find the ID from the guild url rather than an ally code from a random guild member.

Ok but how are you mapping this to swogh.help?

Easy, GuildParser does steps 2-5 for you (minus the googling, as you provided the guild ID). Once it finds an ally code, it will use that as the input to the swgoh.help call.

Ok, ok… but just to be sure, what number are you talking about?

https://swgoh.gg/g/3577/return-of-the-schwartz/

In the above URL, the number you want is 3577.

This is unnecessary, I will always have an ally code

Great! GuildParser is not for you. You can call getGuild() or build your own payload for callAPI() directly. All this wrapper is doing is feting an ally code for you and then calling getGuild() with the FULL_ROSTER option and returning the first item in the result set.

Also note the same rules for the getGuild() callback apply to the argument to scrape(), and if you do not provide a callback then the in memory decoder will be used (and will likely hit PHP's memory limit, unless you have raised it).

Example

Functioning examples

Here are two working Artisan commands using this wrapper

Questions

If you have questions or run into problems, I am available on Discord and hang out on the official api.swgoh.help discord server. Just tag Frax!

License

This wrapper is open-sourced software licensed under the MIT license.


All versions of swgoh-help with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3
fabpot/goutte Version ^3.2
guzzlehttp/guzzle Version ~6.0
illuminate/support Version ~5.4
myclabs/php-enum Version ^1.6
salsify/json-streaming-parser Version ^7.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 matthillman/swgoh-help contains the following files

Loading the files please wait ....