2014-03-26 2 views
0

당신은 https://api.steampowered.com/IDOTA2Match_205790/GetMatchHistory/v001/?key=* 도타 2에서 모든 일치를 얻을 수 있습니다 ** * ***steamid로 사용자를 검색하는 방법은 무엇입니까? 이 링크로

하지만 어떻게 steamid에 의해 하나의 사용자의 일치를 얻을?

+0

@Andy account_id! = steamid – NickUnuchek

+0

@Andy username 또는 link (http://steamcommunity.com/id/URLNAME) 또는 profile_id에서 account_id를 찾는 방법 http://steamcommunity.com/profiles/*** ***? – NickUnuchek

+0

URL 이름에서 프로필 ID를 얻는 방법에 대한 내 대답에 대한 링크를 추가했습니다. – Andy

답변

1

가장 먼저해야 할 일은 STEAM ID를 프로필 ID로 변환하는 것입니다. 이것은 Steam Condenser 프로젝트와 같은 것을 사용하여 수행 할 수 있습니다.보다 간단하게 Steam Condenser 프로젝트의 function입니다. 이 함수를 사용하는 경우 SteamCondenserException이 존재하지 않으므로 던져진 예외를 수정해야합니다. 플레이어 ID가 고유하면 Steam Condenser 프로젝트 전체를 사용하고 answer을 보시기 바랍니다.

/** 
* Converts a SteamID as reported by game servers to a 64bit numeric 
* SteamID as used by the Steam Community 
* 
* @param string $steamId The SteamID string as used on servers, like 
* <var>STEAM_0:0:12345</var> 
* @return string The converted 64bit numeric SteamID 
* @throws SteamCondenserException if the SteamID doesn't have the correct 
* format 
*/ 
    public static function convertSteamIdToCommunityId($steamId) { 
     if($steamId == 'STEAM_ID_LAN' || $steamId == 'BOT') { 
      throw new SteamCondenserException("Cannot convert SteamID \"$steamId\" to a community ID."); 
     } 
     if (preg_match('/^STEAM_[0-1]:[0-1]:[0-9]+$/', $steamId)) { 
      $steamId = explode(':', substr($steamId, 8)); 
      $steamId = $steamId[0] + $steamId[1] * 2 + 1197960265728; 
      return '7656' . $steamId; 
     } elseif (preg_match('/^\[U:[0-1]:[0-9]+\]$/', $steamId)) { 
      $steamId = explode(':', substr($steamId, 3, strlen($steamId) - 1)); 
      $steamId = $steamId[0] + $steamId[1] + 1197960265727; 
      return '7656' . $steamId; 
     } else { 
      throw new SteamCondenserException("SteamID \"$steamId\" doesn't have the correct format."); 
     } 
    } 

이제 64 비트 ID가 있으므로 이미 작성한 API 호출에이 ID를 전달할 수 있습니다. account_id 매개 변수로 전달됩니다. 당신은 일치의 수에 기입하는

$matches = 10; // Return last 10 matches 
$acct = convertSteamIdToCommunityId(STEAMIDYOUARECHECKING); 
$APIKEY = <YOURKEYHERE>; 

$steamurl = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=$APIKEY&account_id=$acct&Matches_Requested=$matches&format=json"; 
$json_object= file_get_contents($steamurl); 
header('Content-Type: application/json'); 
echo $json_object; 

그 조각의 맨 위에있는 세 개의 변수

당신이 반환하려는, 스팀 ID :

PHP에서는이 같은 끝낼 것 사용중인 API 키를 확인하고 있습니다. 결과는 $json_object에 있으며 구문 분석 할 수 있습니다.

+0

예를 들어 내 링크는 http://steamcommunity.com/profiles/76561198125073633/ account_id를받는 방법은 무엇입니까? – NickUnuchek

+0

아, 미안 해요 이미 증기입니다 76561198125073633 – NickUnuchek