public void ValidateData() { ConnectionData = _instaApi.ConnectionData ?? new FbnsConnectionData(); var unix = DateTime.UtcNow.ToUnixTime(); if (ConnectionData.FbnsTokenUpdatedAt > 0 && (unix.FromUnixTimeSeconds() - ConnectionData.FbnsTokenUpdatedAt.FromUnixTimeSeconds()).TotalHours > 24) { ConnectionData.FbnsToken = ""; ConnectionData.FbnsTokenUpdatedAt = 0; } if (string.IsNullOrEmpty(ConnectionData.UserAgent)) { ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(_instaApi); } }
public void ValidateData() { ConnectionData = _instaApi.ConnectionData ?? new FbnsConnectionData(); // If token is older than 24 hours then discard it var unix = DateTime.UtcNow.ToUnixTime(); if (ConnectionData.FbnsTokenUpdatedAt > 0 && (unix.FromUnixTimeSeconds() - ConnectionData.FbnsTokenUpdatedAt.FromUnixTimeSeconds()).TotalHours > 24) { // token expired, so we need to a new token. ConnectionData.FbnsToken = ""; ConnectionData.FbnsTokenUpdatedAt = 0; } // Build user agent for first time setup if (string.IsNullOrEmpty(ConnectionData.UserAgent)) { ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(_instaApi); } }
public PushClient(List <IInstaApi> apis, IInstaApi api /*, bool tryLoadData = true*/) { _runningTokenSource = new CancellationTokenSource(); ApiList = apis; _instaApi = api ?? throw new ArgumentException("Api can't be null", nameof(api)); //if (tryLoadData) ConnectionData.LoadFromAppSettings(); ConnectionData = api.ConnectionData ?? new FbnsConnectionData(); // If token is older than 24 hours then discard it if ((DateTimeOffset.Now - ConnectionData.FbnsTokenLastUpdated).TotalHours > 24) { ConnectionData.FbnsToken = ""; } // Build user agent for first time setup if (string.IsNullOrEmpty(ConnectionData.UserAgent)) { ConnectionData.UserAgent = FbnsUserAgent.BuildFbUserAgent(api); } }