public static string GetSessionId() { string signature = SpyToolUtils.GetSignature("testsession"); Debug.WriteLine("\nChecking current session ...."); string requestURI = SpyToolUtils.GetRequestURI("testsession", authParams: false, Credentials.DevId, signature, sessionInfo.session_id, GetSessionTimestamp()); string responseFromServer = SpyToolUtils.GetServerResponse(requestURI); // create a new session if necessary if (responseFromServer == null || responseFromServer.Contains("Invalid") || responseFromServer.Contains("Exception")) { SessionInfo newSessionInfo = SpyToolUtils.CreateSession(); Debug.WriteLine($"\nPast APISession Id was Invalid ({sessionInfo.session_id}).\nNew APISession Id is: {newSessionInfo.session_id}"); sessionInfo = newSessionInfo; SaveSessionInfo(); } else { Debug.WriteLine($"\n Past APISession Id was Valid!"); } return(sessionInfo.session_id); }
public static string GetSessionTimestamp() { DateTime timestamp = sessionInfo.timestamp; // create a new session if necessary if (timestamp == null || timestamp == DateTime.MinValue) { SessionInfo newSessionInfo = SpyToolUtils.CreateSession(); Debug.WriteLine($"\nPast Timestamp is Invalid ({timestamp}).\nNew Timestamp is: {newSessionInfo.timestamp}"); sessionInfo = newSessionInfo; SaveSessionInfo(); } return(sessionInfo.GetTimestampString()); }