Code Monkey home page Code Monkey logo

gw2apiclient's Introduction

GW2 Api Client

This project can be used to request GW2 api through PHP.

The classes I wrote are robust : retries when the api is not well responding, it manages long list of ids (making several requests and returning to you the whole response), and so on.

Init objects

// init Environment
$env = new Arnapou\GW2Api\Environment();

// init cache (here it is a Mongo cache, but it can be a file cache or whatever you want)
$mongo   = MongoDB\Client('mongodb://localhost:27017', [], ['typeMap' => ['root' => 'array', 'document' => 'array']]);
$mongoDB = $mongo->selectDatabase("my_db");
$cache   = new Arnapou\GW2Api\Cache\MongoCache($mongoDB);
$env->setCache($cache);

// init storage (optional, but recommended, here, we used the same mongo database as before)
$storage = new Arnapou\GW2Api\Storage\MongoStorage($mongoDB);
$env->setStorage($storage);

// set lang (en, fr, de, es)
$env->setLang('en');

// set access token
$env->setAccessToken('A7B98574-1757-8048-B640-55C2D3F46727BB6E108E-E011-4501-B0BB-B2731E90785D');

Browse account through objects (use storage if set)

$account = new Arnapou\GW2Api\Model\Account($env);

$account->getWorld()->getName();

$account->getCharacter('My Character Name')->getEquipment('Helm')->getName();

Use api to retrieve raw api data (ignore storage, only cache is used)

$env->getClientVersion1()->apiColors();

$env->getClientVersion2()->apiItems([21141,65230]);

Fully custom use

// get api raw data
$data = $env->getClientVersion2()->apiPets([28]);

// instanciate object with data and use it as you wish
$pet = new Arnapou\GW2Api\Model\Pet($env, $data[0]);
$pet->getName();

Requirements

  • PHP 7+
  • PECL extension mongodb version >=1.1.0 and <2.0.0

gw2apiclient's People

Contributors

arnapou avatar

Stargazers

Ewilan Rivière avatar Michael avatar DeaJae avatar  avatar

Watchers

James Cloos avatar  avatar  avatar

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.