Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Retrieving Twitter Server time

$
0
0
Hi,

I'm looking to retrieve the server time from twitter. It should be included in the response's header. Does the API support this?

In the meantime, I have made a local change to the IToken interface to include a property for the server's datetime:
    public DateTime ServerTime { get; set; }
And inside private Dictionary<string, object>[] ExecuteQuery I changed this:
if (_lastHeadersResult != null && _lastHeadersResult["X-RateLimit-Remaining"] != null)
{
    XRateLimitRemaining = Int32.Parse(_lastHeadersResult["X-RateLimit-Remaining"]);
}
To this:
if (_lastHeadersResult != null)
{
    if (_lastHeadersResult["X-RateLimit-Remaining"] != null)
    {
        XRateLimitRemaining = Int32.Parse(_lastHeadersResult["X-RateLimit-Remaining"]);
    }
    if (_lastHeadersResult["Date"] != null)
    {
        DateTime serverTime;
        if (DateTime.TryParse(_lastHeadersResult["Date"], out serverTime))
        {
            ServerTime = serverTime;
        }
    }
}
_kurt

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>