-
Notifications
You must be signed in to change notification settings - Fork 0
/
paladins-api.php
172 lines (167 loc) · 9.49 KB
/
paladins-api.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
require 'vendor/autoload.php';
class HiRezAPI {
var $devKey;
var $devAuthID;
var $platform;
var $language;
public function devkey($devkey){
$this->devkey = $devkey;
}
public function devAuthID($devAuthID){
$this->devAuthID = $devAuthID;
}
public function platform($input = 'pc'){
$platforms = array(
'pc' => 'http://api.paladins.com/paladinsapi.svc',
'xbox' => 'http://api.xbox.paladins.com/paladinsapi.svc',
'ps4' => 'http://api.ps4.paladins.com/paladinsapi.svc'
);
if (!array_key_exists($input, $platforms)){
$input = 'pc';
}
$this->platform = $platforms[$input];
}
public function language($langcode = 'en'){
$langArray = array(
'en' => '1',
'ger' => '2',
'fr' => '3',
'ch' => '5',
'esp' => '7',
'esp-latin' => '9',
'pt' => '10',
'ru' => '11',
'pl' => '12',
'tr' => '13'
);
$this->language = $langArray[$langcode];
}
private function GenerateSignature ($method) {
$str = $this->devkey . $method . $this->devAuthID . $this->TimeStamp ();
return md5($str);
}
private function TimeStamp () {
return gmdate('YmdHis');
}
private function Session () {
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/createsessionjson/" . $this->devkey . "/" . $this->GenerateSignature ("createsession") . '/' . $this->TimeStamp ());
}
//APIs - Connectivity
public function Ping(){
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/pingJson")->getBody();
}
public function CreateSession() {
$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
if($memcache->get('sessionid') == ''){
$session = json_decode($this->Session()->getBody(), true);
$memcache->set('sessionid', $session['session_id'],false,900);
return $memcache->get('sessionid');
}else{
return $memcache->get('sessionid');
}
}
public function TestSession(){
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/testsessionJson/" . $this->devkey . "/" . $this->GenerateSignature("testsession") . "/" . $this->CreateSession() . "/" . $this->TimeStamp() )->getBody();
}
public function GetHirezServerStatus(){
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/gethirezserverstatusJson/" . $this->devkey . "/" . $this->GenerateSignature("gethirezserverstatus") . "/" . $this->CreateSession() . "/" . $this->TimeStamp() )->getBody();
}
//APIs
public function GetDataUsed () {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getdatausedJson/" . $this->devkey . "/" . $this->GenerateSignature ("getdataused") . "/" . $this->CreateSession() . "/" . $this->TimeStamp ())->getBody();
}
public function GetDemoDetails ($matchId) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getdemodetailsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getdemodetails") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $matchId)->getBody();
}
public function GetEsportsProLeagueDetails () {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getesportsproleaguedetailsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getesportsproleaguedetails") . "/" . $this->CreateSession() . "/" . $this->TimeStamp ())->getBody();
}
public function GetFriends ($player) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getfriendsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getfriends") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player)->getBody();
}
public function GetChampionRanks ($player) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getchampionranksJson/" . $this->devkey . "/" . $this->GenerateSignature ("getchampionranks") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player)->getBody();
}
public function GetChamps(){
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getchampionsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getchampions") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $this->language)->getBody();
}
public function GetChampionSkins($champName = 'Androxus'){
$json = $this->GetChamps();
$champs = json_decode($this->GetChamps(), true);
foreach( $champs as $index=>$json ){
if( $champName == $json['Name']){
$champID = json_decode($json['id'], true);
}
}
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getchampionskinsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getchampionskins") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $champID . "/" . $this->language)->getBody();
}
public function GetItems () {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getitemsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getitems") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $this->language)->getBody();
}
public function GetMatchDetails ($matchId) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getmatchdetailsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getmatchdetails") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $matchId)->getBody();
}
public function GetMatchPlayerDetails ($matchId) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getmatchplayerdetailsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getmatchplayerdetails") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $matchId)->getBody();
}
public function GetMatchHistory ($player) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getmatchhistoryJson/" . $this->devkey . "/" . $this->GenerateSignature ("getmatchhistory") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player)->getBody();
}
public function GetMotd () {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getmotdJson/" . $this->devkey . "/" . $this->GenerateSignature ("getmotd") . "/" . $this->CreateSession() . "/" . $this->TimeStamp ())->getBody();
}
public function GetPlayer ($player) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getplayerJson/" . $this->devkey . "/" . $this->GenerateSignature ("getplayer") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player)->getBody();
}
public function GetPlayerLoadouts ($player) {
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getplayerloadoutsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getplayerloadouts") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player . "/" . $this->language)->getBody();
}
public function GetPlayerStatus ($player) {
/*
0 - Offline
1 - In Lobby (basically anywhere except god selection or in game)
2 - god Selection (player has accepted match and is selecting god before start of game)
3 - In Game (match has started)
4 - Online (player is logged in, but may be blocking broadcast of player state)
5 - Unknown (player not found)
*/
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getplayerstatusJson/" . $this->devkey . "/" . $this->GenerateSignature ("getplayerstatus") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $player)->getBody();
}
public function GetTopMatches() {
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/gettopmatchesJson/" . $this->devkey . "/" . $this->GenerateSignature("gettopmatches") . "/" . $this->CreateSession() . "/" . $this->TimeStamp())->getBody();
}
public function GetPlayerAchievements ($player) {
$ids = json_decode($this->GetPlayer($player), true);
foreach( $ids as $id ){
$playerId = $id['Id'];
}
$client = new GuzzleHttp\Client();
return $client->request("GET",$this->platform . "/getplayerachievementsJson/" . $this->devkey . "/" . $this->GenerateSignature ("getplayerachievements") . "/" . $this->CreateSession() . "/" . $this->TimeStamp () . "/" . $playerId)->getBody();
}
public function GetPatchInfo() {
$client = new GuzzleHttp\Client();
return $client->request("GET", $this->platform . "/getpatchinfoJson/" . $this->devkey . "/" . $this->GenerateSignature("getpatchinfo") . "/" . $this->CreateSession() . "/" . $this->TimeStamp())->getBody();
}
}