dolejska-daniel / riot-api

Riot League of Legends & DataDragon API wrappers for PHP7 and PHP8.
GNU General Public License v3.0
112 stars 25 forks source link

DataDragon API #9

Closed Tiposbingo closed 6 years ago

Tiposbingo commented 6 years ago

Hi again, is there any more info about DataDragon API ? implementation, maybe some example ?

Thank you.

dolejska-daniel commented 6 years ago

Hello,

DataDragon implementation is currently not documented, so the only way to check how it works is to read function documentation comments directly in file.

I can briefly introduce it for you:

  1. You need to initialize the library using one of these functions:
    • DataDragonAPI::initByCdn(), this will fetch latest version of DD from DD itself
    • DataDragonAPI::initByRegion('eune'), this will fetch latest version of DD from provided region (eune, euw, etc. -- make sure its lowercase)
    • DataDragonAPI::initByVersion('8.1.1'), this will explicitly specify requested version of DD, makes no request
    • DataDragonAPI::initByApi($api), this function requires instance of RiotAPI and will request realm (region) object from API and use it to read current DD version
    • DataDragonAPI::initByRealmObject($realm), this function accepts realm (region) object on its own, makes no request
  2. You use static functions to get what you want!
    • DataDragonAPI::getProfileIcon(50), this function returns instance of Html class, which on __toString() automatically renders itself as an <img> tag, with all the required attributes to display the image.

If you've got any further questions, feel free to ask 😺

Tiposbingo commented 6 years ago

Thank you very much 🥇

Tiposbingo commented 6 years ago

I find small issue. When you initalize the library using DataDragonAPI::initByApi($api) and then DataDragonAPI::getProfileIcon(50) return this link http://ddragon.leagueoflegends.com/cdn8.1.1/img/profileicon/588.png but you need cdn/8.1.1

dolejska-daniel commented 6 years ago

@Tiposbingo thanks! There was a bug, CDN link was not formed correctly when initialized by API or RealmObject. It should be fixed in cdd5e08.

dolejska-daniel commented 6 years ago

@Tiposbingo, I've updated DataDragonAPI's wiki pages, feel free to check them out 😸

Tiposbingo commented 6 years ago

@dolejska-daniel thanks, I'll test it with my laravel app soon