Code: Select all
Public Class SteamIDInfo
Public Function GetSteamIDInfo(ByVal Type As String, ByVal ID As String, ByVal Element As String)
If String.IsNullOrEmpty(ID) Then
Return Nothing
End If
Dim reqUrl As String = "http://steamcommunity.com/" + Type + "/" + ID + "/?xml=1"
Dim httpReq As HttpWebRequest = TryCast(HttpWebRequest.Create(reqUrl), HttpWebRequest)
Try
Dim result As String = String.Empty
Dim response As HttpWebResponse = TryCast(httpReq.GetResponse(), HttpWebResponse)
Using reader = New StreamReader(response.GetResponseStream())
result = reader.ReadToEnd()
End Using
Return ProcessResponse(result, Element)
Catch ex As Exception
Throw
End Try
End Function
Private Function ProcessResponse(ByVal strResp As String, ByVal TheElement As String)
Dim Result As String = Nothing
Dim sr As New StringReader(strResp)
Dim respElement As XElement = XElement.Load(sr)
Dim tmpEle As String = respElement.Element(TheElement)
Return tmpEle
End Function
End Class
Code: Select all
Private Shared intBigNum As Long = 76561197960265728
Private Function GetCommunityId(ByVal pSteamId As String) As String
pSteamId = Trim(pSteamId)
pSteamId = UCase(pSteamId)
Dim strRegEx As String = "\bSTEAM_[0-1]:[0-1]:(\d+)\b"
If RegularExpressions.Regex.IsMatch(pSteamId, strRegEx) Then
pSteamId = pSteamId.Substring(6)
Dim arrParts() As String = pSteamId.Split(":")
Dim intAuthSvr1 As Integer = arrParts(0)
Dim intAuthSvr2 As Integer = arrParts(1)
Dim intClientNum As Long = arrParts(2)
Return CType(intBigNum + intAuthSvr2 + (intClientNum * 2), String)
Else
Return CStr(0)
End If
End Function
Private Function GetSteamId(ByVal pCommunityId As String) As String
If pCommunityId.Length = 17 And IsNumeric(pCommunityId) = True Then
Dim intCommunityId As Long = CType(pCommunityId, Long)
Dim intAuthSvr1 As Integer = 0
Dim intAuthSvr2 As Integer = Nothing
If intCommunityId Mod 2 Then
intAuthSvr2 = 1
Else
intAuthSvr2 = 0
End If
Dim intClientNum As Long = (intCommunityId - intBigNum - intAuthSvr2) / 2
Return "STEAM_" & CStr(intAuthSvr1) & ":" & CStr(intAuthSvr2) & ":" & CStr(intClientNum)
Else
Return CStr(0)
End If
End Function