/
simpleserver.php
73 lines (64 loc) · 2.12 KB
/
simpleserver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
header("Access-Control-Allow-Origin: *");
$apiKey = '941d558c-76a3-4e0a-b90a-1c59c34623cd';
if (isset($_REQUEST['action'])) {
session_start();
switch ($_REQUEST['action']) {
case 'getSummonerData':
getSummonerData($_REQUEST['summonerName']);
break;
case 'getRankedStatsData':
getRankedStatsData($_REQUEST['summonerId']);
break;
case 'getChampionData':
getChampionData();
break;
case 'getSummonerRank':
getSummonerRank($_REQUEST['summonerId']);
break;
case 'getChampionRoles':
getChampionRoles();
break;
}
}
function getSummonerData($summonerName) {
// get the basic summoner info
$result = 'https://na.api.pvp.net/api/lol/na/v1.4/summoner/by-name/' . $summonerName . '?api_key=' . $GLOBALS['apiKey'];
$summoner = curl_get_contents($result);
echo $summoner;
}
function getSummonerRank($summonerId) {
// get the basic summoner info
$result = 'https://na.api.pvp.net/api/lol/na/v2.5/league/by-summoner/' . $summonerId . '?api_key=' . $GLOBALS['apiKey'];
$summoner = curl_get_contents($result);
echo $summoner;
}
function getRankedStatsData($summonerId) {
$result = 'https://na.api.pvp.net/api/lol/na/v1.3/stats/by-summoner/' . $summonerId . '/ranked?api_key=' . $GLOBALS['apiKey'];
$rankedStatsData = curl_get_contents($result);
echo $rankedStatsData;
}
function getChampionData() {
$result = 'https://na.api.pvp.net/api/lol/static-data/na/v1.2/champion/?champData=all&api_key=' . $GLOBALS['apiKey'];
$championData = curl_get_contents($result);
echo $championData;
}
function getChampionRoles() {
// get the basic summoner info
$result = 'http://127.0.0.1:8081/LeagueOfLegendsServer/ChampionList.json';
$summoner = curl_get_contents($result);
echo $summoner;
}
function curl_get_contents($url)
{
$ch = curl_init($url);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
?>