<?php
require 'lib/elophant.class.php';
$elophant = new Elophant(array(
'apiKey' => 'ecfQ7fDTnKqHsdasdd',
'lolServer' => 'euw'
));
//Return some Summoner data
$summonerData = $elophant->getSummonerByName('edocsyl');
echo '<pre>';
print_r($summonerData);
echo '</pre>';
//Return the most played champions
$accountId = $elophant->getAccountId('edocsyl');
$mostPlayedChampion = $elophant->getMostPlayedChampions($accountId);
echo '<pre>';
print_r($mostPlayedChampion);
echo '</pre>';
?><?php
/**
* Elophant.com - PHP API
*
* @author Kaj <EUW Summoner: Edocsyl>
* @since 14.11.2012
* @copyright Kaj <kaj@edocsyl.ch>
* @website http://edocsyl.ch/
* @version 1.1
* @license BSD http://www.opensource.org/licenses/bsd-license.php
* @docs http://elophant.edocsyl.ch/ | http://elophant.com/developers/docs
*/
class Elophant{
/**
* The API base URL
*/
const API_URL = "http://elophant.com/api/v1/";
/**
* Lol Server Shortcuts
*
* @var array
*/
private $_lolServers = array('na', 'euw', 'eune', 'br');
/**
* Elophant API Key
*
* @var string
*/
private $_apiKey;
/**
* Lol Server
*
* @var string
*/
private $_lolServer;
/**
* Default constructor
*
* @param array|string $config - Config Array
* @return void
*/
public function __construct($config){
if (true === is_array($config)){
$this->setApiKey($config['apiKey']);
$this->setLolServer($config['lolServer']);
} else {
throw new Exception("Error: __construct() - Configuration data is missing.");
}
}
/***************** API FUNCTIONS ************************************************************/
/**
* Returns the current status of every region.
*
* @return json decode
*/
public function getStatus(){
return $this->_makeCall('status?');
}
/**
* Returns every items's id and name in Json.
*
* @return json decode
*/
public function getItems(){
return $this->_makeCall('items?');
}
/**
* Returns every champion's id and name in Json.
*
* @return json decode
*/
public function getChampions(){
return $this->_makeCall('champions?');
}
/**
* Get the Summoner ID
*
* @param string $summonerName - Summoner Name
* @return string - Summoner ID
*/
public function getSummonerId($summonerName){
return $this->getSummonerByName($summonerName)->summonerId;
}
/**
* Get the Account ID
*
* @param string $summonerName - Summoner Name
* @return string - Account ID
*/
public function getAccountId($summonerName){
return $this->getSummonerByName($summonerName)->acctId;
}
/**
* Get the Account ID
*
* @param string $summonerName - Summoner Name
* @return string - Account ID
*/
public function getSummonerByName($summonerName){
$summonerName = str_replace(' ', '%20', $summonerName);
return $this->_makeCall($this->_lolServer . '/getSummonerByName?summonerName=' . $summonerName . '&');
}
/**
* Returns the player information for both teams.
*
* @param string $summonerName - Summoner Name
* @return json decode
*/
public function getInProgressGameInfo($summonerName){
return $this->_makeCall($this->_lolServer . '/getInProgressGameInfo?summonerName=' . $summonerName . '&');
}
/**
* Returns a summoner's 3 most played champions from their ranked statistics.
*
* @param string $accountId - Summoner Account ID
* @return json decode
*/
public function getMostPlayedChampions($accountId){
return $this->_makeCall($this->_lolServer . '/getMostPlayedChampions?accountId=' . $accountId . '&');
}
/**
* Returns all team info regarding the specified summoner.
*
* @param string $summonerId - Summoner ID
* @return json decode
*/
public function getSummonerTeamInfo($summonerId){
return $this->_makeCall($this->_lolServer . '/getSummonerTeamInfo?summonerId=' . $summonerId . '&');
}
/**
* Returns an array with each mastery book page.
*
* @param string $summonerId - Summoner ID
* @return json decode
*/
public function getMasteryPages($summonerId){
return $this->_makeCall($this->_lolServer . '/getMasteryPages?summonerId=' . $summonerId . '&');
}
/**
* Returns an array with each rune page.
*
* @param string $summonerId - Summoner ID
* @return json decode
*/
public function getRunePages($summonerId){
return $this->_makeCall($this->_lolServer . '/getRunePages?summonerId=' . $summonerId . '&');
}
/**
* Returns an array of summoner names in the same order as provided in the parameter summonerIds.
*
* @param array $summonerIds - Summoner ID's
* @return json decode
*/
public function getSummonerNames($summonerIds = array()){
$summonerId = null;
foreach($summonerIds as $id){
$summonerId = $summonerId . $id . ',';
}
return $this->_makeCall($this->_lolServer . '/getSummonerNames?summonerIds=' . substr($summonerId, 0, -1) . '&');
}
/**
* Returns an overview of the statistics for each game mode for the specified summoner.
*
* @param string $accountId - Summoner Account ID
* @param string $lolSeason - Example Values: CURRENT or ONE
* @return json decode
*/
public function getPlayerStats($accountId, $lolSeason){
return $this->_makeCall($this->_lolServer . '/getPlayerStats?accountId=' . $accountId . '&season=' . $lolSeason . '&');
}
/**
* Returns every statistic for every champion accumulated from all ranked game types for a specified summoner and season.
*
* @param string $accountId - Summoner Account ID
* @param string $lolSeason - Example Values: CURRENT or ONE
* @return json decode
*/
public function getRankedStats($accountId, $lolSeason){
return $this->_makeCall($this->_lolServer . '/getPlayerStats?accountId=' . $accountId . '&season=' . $lolSeason . '&');
}
/**
* Returns a brief overview of a team, including gameType dependent Elos, the current roster, and basic match history statistics.
*
* @param string $teamName - Team Name | Example Value: tsm or Team Solo Mid
* @return json decode
*/
public function getTeamByTagOrName($teamName){
$teamName = str_replace(' ', '%20', $teamName);
return $this->_makeCall($this->_lolServer . '/getTeamByTagOrName?tagOrName=' . $teamName . '&');
}
/**
* Returns the Team ID
*
* @param string $teamName - Team Name | Example Value: tsm or Team Solo Mid
* @return string
*/
public function getTeamId($teamName){
return $this->getTeamByTagOrName($teamName)->teamId->fullId;
}
/**
* Returns a brief overview of a team, including gameType dependent Elos, the current roster, and basic match history statistics.
*
* @param string $teamId - Team ID | Example Value: TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995
* @return json decode
*/
public function getTeamById($teamId){
return $this->_makeCall($this->_lolServer . '/getTeamById?teamId=' . $teamId . '&');
}
/**
* Returns very detailed statistics about the specified match.
*
* @param string $teamId - Team ID | Example Value: TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995
* @param string $gameId - Game ID | Example Value: 357749707
* @return json decode
*/
public function getTeamEndOfGameStats($teamId, $gameId){
return $this->_makeCall($this->_lolServer . 'getTeamEndOfGameStats?teamId=' . $teamId . '&gameId=' . $gameId . '&');
}
/**
* Returns each team member's statistics for the specified team.
*
* @param string $teamId - Team ID | Example Value: TEAM-e4936d7b-b80e-4367-a76c-5ccf7388c995
* @return json decode
*/
public function getTeamRankedStats($teamId){
return $this->_makeCall($this->_lolServer . '/getTeamRankedStats?teamId=' . $teamId . '&');
}
/***************** SOME STUFF ************************************************************/
/**
* Makes the Call
*
* @param string $function - The function
* @return json decode
*/
private function _makeCall($function){
$apiCall = self::API_URL . $function . $this->_apiKey;
//$callData = file_get_contents($apiCall);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiCall);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
$callData = curl_exec($ch);
curl_close($ch);
return json_decode($callData);
}
/**
* Check if server shortcut is valid
*
* @param string $lolServer - Server shortcut
* @return true|false
*/
private function checkServer($lolServer){
if(in_array(strtolower($lolServer), $this->_lolServers)){
return true;
} else {
return false;
}
}
/**
* API Key setter
*
* @param string $apiKey - Elophant API Key
* @return void
*/
private function setApiKey($apiKey){
$this->_apiKey = 'key=' . $apiKey;
}
/**
* Server shortcut setter
*
* @param string $lolServer - Lol Server shortcut
* @return void
*/
public function setLolServer($lolServer){
if($this->checkServer($lolServer)){
$this->_lolServer = $lolServer;
} else {
throw new Exception("Error: __construct() - Configuration wrong lol server.");
}
}
}
?>boyle birşeymi?
--R10.NET; Flood Engellendi -->-> Yeni yazılan mesaj 16:12:16 -->-> Daha önceki mesaj 14:24:47 --
yardımcı olablicek kimse yokmu?