Git Product home page Git Product logo

blizzard_api_php's Introduction

Blizzard API client

This library is an interface to Blizzard APIS.

See https://develop.battle.net/ for more information.

Installation

This library requires PHP 8.1 or newer with the following modules:

  • mbstring
  • curl
  • redis (Only if using the Redis cache interface)

You can add this library to your compose project by adding francis-schiavo/blizzard_api as a requirement on your compose.json.

or from the command line:

php composer.phar require francis-schiavo/blizzard_api

Configuration

You must configure the package with a valid pair of credentials. You can obtain them here: https://develop.battle.net/access/clients

The code sample below show how to configure the library.

<?php

use BlizzardApi\Enumerators\Region;

BlizzardApi\Configuration::$apiKey = '<YOUR APPLICATION ID>';
BlizzardApi\Configuration::$apiSecret = '<YOUR APPLICATION SECRET>';
BlizzardApi\Configuration::$region = Region::US;

Basic usage

This is how you can get a list of all available wow playable races:

$api_client = new \BlizzardApi\Wow\GameData\PlayableRace();
$data = $api_client->index();

echo(print_r($data));

You can pass an instance of RedisCache to use Redis to cache API requests locally:

# PHP Redis module
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$redis->select(8);

# BlizzardApi\Cache
use BlizzardApi\Cache\RedisCache;
$cache = new RedisCache($redis);

# Pass the constructor `cache` parameter.
$api_client = new \BlizzardApi\Wow\GameData\PlayableRace(cache: $cache);
$data = $api_client->index();

Advanced search interface

For some WoW endpoints there is a search method available, you can easily compose a valid query as shown here:

# Pass the constructor `cache` parameter.
$api_client = new \BlizzardApi\Wow\GameData\Item(cache: $cache);
$data = $api_client->search(function($queryOptions) {
    $searchOptions->where('name.en_US', 'Booterang')->order_by('id');
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.