Flex mobile request to time.nist.gov

414 views Asked by At

How do I access the time provided by internet time services like time.nist.gov from within my Flex mobile application?

Is there a way to do this via URLRequest or HTTPService?

Alright, here is the call to the Yahoo WebServices with a simple HTTPService;

<s:HTTPService id="serverTime" url="http://developer.yahooapis.com/TimeService/V1/getTime?appid=myID" result="resultHandler(event)" resultFormat="e4x"/>

In my resultHandler, the trace on Timestamp already fails (returns no value);

private function resultHandler(event:ResultEvent):void {
            // this works (outputs the xml as shown on Yahoo
            trace(event.result);

            var xmlResult:XML = event.result as XML;
            var timestamp:String = xmlResult.Timestamp;

            trace("stamp" + timestamp);
}
1

There are 1 answers

2
Radu Cugut On BEST ANSWER

time.nist.gov (or any other time server) use NTP protocol for communication, not HTTP, so you can't use URLRequest or HTTPService. I don't know of any NTP client implementation in ActionScript. You may need to do your own.

Depending on your needs, you may use a webservice that provides "pretty accurate" time, like Yahoo WebServices. This goes over HTTP, so you can use URLRequest or HTTPService in Flex.