Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $devKey = '2BD1AA14D090F3EC860C750FDB0CBA77';
- $accountID = 32436608;
- $url = 'https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=' . $devKey;
- $matches = array();
- $lastMatchID = 0;
- $ch = curl_init();
- $options = array(
- CURLOPT_RETURNTRANSFER => 1,
- CURLOPT_SSL_VERIFYPEER => 0,
- CURLOPT_SSL_VERIFYHOST => 0
- );
- curl_setopt_array($ch, $options);
- for ($i = 1; $i <= 10; $i++) {
- curl_setopt($ch, CURLOPT_URL, $url . '&account_id=' . $accountID . '&start_at_match_id=' . $lastMatchID . '&matches_requested=51');
- $response = json_decode(curl_exec($ch), TRUE);
- $matches = array_merge($matches, $response['result']['matches']);
- $lastMatchKey = count($matches) - 1;
- $lastMatchID = $matches[$lastMatchKey]['match_id'];
- if ($i < 10) {
- unset($matches[$lastMatchKey]);
- }
- }
- function checkIfRanked($match) {
- $lobbyType = $match['lobby_type'];
- if ($lobbyType == 7) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
- function checkIfFullStack($match) {
- $players = $match['players'];
- $ourIDs = array(32436608, 89759793, 111340921, 141605683, 192150916);
- $counter = 0;
- for ($i = 0; $i <= 9; $i++) {
- $playerID = $players[$i]['account_id'];
- if (in_array($playerID, $ourIDs)) {
- $counter++;
- }
- }
- if ($counter == 5) {
- return TRUE;
- } else {
- return FALSE;
- }
- }
- foreach ($matches as $key => &$value) {
- if (!checkIfRanked($value) || !checkIfFullStack($value)) {
- unset($matches[$key]);
- }
- }
- $allIDs = array();
- foreach (array_values($matches) as $value) {
- $allIDs[] = $value['match_id'];
- }
- $url = 'https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key=' . $devKey;
- $matchesDetailed = array();
- foreach ($allIDs as $value) {
- curl_setopt($ch, CURLOPT_URL, $url . '&match_id=' . $value);
- $response = json_decode(curl_exec($ch), TRUE);
- $matchesDetailed[] = $response['result'];
- }
- curl_close($ch);
- print "<pre>";
- print_r($matchesDetailed);
- print "</pre>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment