PHP code example of matthillman / swgoh-help

1. Go to this page and download the library: Download matthillman/swgoh-help library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

matthillman / swgoh-help example snippets




return [

    # ... all the other config blocks

    'swgoh_help' => [
        'user' => env('SWGOH_HELP_USER'),
        'password' => env('SWGOH_HELP_PASSWORD'),
    ],

];

// Retrieve all mods for a user
$mods = swgoh()->getMods('552325555');

[
    "allycode" => $allyCode,
    "language" => $this->lang,
    "enums" => $this->enums,
    "project" => array_merge([
        "allyCode" => 1,
        "name" => 1,
        "level" => 1,
        "guildName" => 1,
        "stats" => 1,
        "roster" => 0,
        "arena" => 1,
        "updated" => 1,
    ], $projection),
]

[
    "allycode" => $allyCode,
    "mods" => $mods,
    "language" => $this->lang,
    "enums" => $this->enums,
    "project" => array_merge([
        "player" => 0,
        "allyCode" => 0,
        "starLevel" => 1,
        "level" => 1,
        "gearLevel" => 1,
        "gear" => 1,
        "zetas" => 1,
        "type" => 1,
        "mods" => $mods ? 1 : 0,
        "gp" => 1,
        "updated" => 0,
    ], $projection),
]

$data = [
    "player" => 0,
    "allyCode" => 0,
    "starLevel" => 0,
    "level" => 0,
    "gearLevel" => 0,
    "gear" => 0,
    "zetas" => 0,
    "type" => 0,
    "mods" => 1,
    "gp" => 0,
    "updated" => 0,
];

$rosterInner = [
    "defId" => 1,
    "rarity" => 1,
    "level" => 1,
    "gear" => 1,
    "combatType" => 1,
    "gp" => 1,
    "skills" => 1,
    "mods" => $mods ? 1 : 0,
];
$data = [
    "allycode" => $allyCode,
    "roster" => $fullRoster == static::FULL_ROSTER,
    "units" => $fullRoster == static::FULL_UNITS,
    "mods" => $mods,
    "language" => $this->lang,
    "enums" => $this->enums,
    "project" => array_merge([
        "name" => 1,
        "desc" => 1,
        "members" => 1,
        "status" => 1,
        "

$data = [
    "collection" => "unitsList",
    "language" => $this->lang,
    "enums" => $this->enums,
    "match" => array_merge([ "rarity" => 7 ], $match),
    "project" => array_merge([
        "baseId" => 1,
        "nameKey" => 1,
        "thumbnailName" => 1,
        "basePower" => 1,
        "descKey" => 1,
        "combatType" => 1,
        "forceAlignment" => 1,
        "combatType" => 1,
        "skillReferenceList" => [ "skillId" => 1 ],
    ], $projection),
];

[
    [
        'name' => <human readable ability name>,
        'id' => <maps to a skill_id, eg: 'uniqueskill_LOGRAY01'>,
        'class' => <Unique|Special|Leader>
       ]
    ]
]

    const API_PLAYER = 'player';
    const API_UNITS = 'units';
    const API_GUILD = 'guild';
    const API_DATA = 'data';

# helper function
swgoh();
# construction
$swogh = new SwgohHelp\API;

# object
$swgoh->lang = 'eng_us';
$swogh->enums = false;
$swogh->callAPI();

# helpers
swgoh()->lang('eng_us')->withoutEnums()->callAPI();

$parser = new SwoghHelp\Parsers\ProfileParser('552325555');
$parser->scrape();
# The user data
$parser->getUser();
# The updated date
$parser->updated();

[
    [
        'uid' => $mod['id'],
        'slot' => (new ModSlot($index))->getKey(),
        'set' => (new ModSet(+$mod['set']))->getKey(),
        'pips' => $mod['pips'],
        'level' => $mod['level'],
        'tier' => $mod['tier'],
        'location' => $char,

        'primary' => ['type' => <type enum>, 'value' => <value>],
        'secondaries' => [
            'type' => ['value' => <value>, 'roll' => <roll>],
            ...
        ],
    ],
    ...
]

$parser = new SwoghHelp\Parsers\ModsParser('552325555');
$parser->scrape();
# The mod data
$parser->getMods();

$parser = new SwoghHelp\Parsers\GuildParser('3577');
$parser->scrape(function($member_data) {
    # Do something with the member data
});
# The guild data (minus the roster key if you provided a callback)
$parser->data;
# Guild name
$parser->name();
# Guild GP
$parser->gp();
# Guild roster (if you did not provide a callback, if you did this is null)
$parser->members();
# Guild's swogh.gg url
$parser->url();