TimeZoneAuthority-Logo
Login / Register
@email*()
Authentication by:1id
empty
empty
Resources
 
Technical Training
TimeZoneAuthority.com Technical Training specializes in working with top-level IS professionals to assess and implement short- and long-term strategic training solutions. Our focus enables us to customize training for each client to:
 * Minimize downtime
 * Respond quickly to business unit demands
 * Show exceptional ROI for training investment
 * Offer the greatest depth of course offerings in the area.

Programming Solutions
A variety of research resources on functional programming languages, implementation, and applications for our products.
 ASP .NET
 C
 Cold Fusion Markup Language
 Java / JSP
 Perl
 PHP
 Python
 Ruby

ASP .NET
 <%
 Dim objWinHttp ' Start out declaring our variables.
 Dim strHTML ' You are using Option Explicit aren't you?
 Set objWinHttp = Server.CreateObject("WinHttp.WinHttpRequest.5.1") ' New WinHTTP v5.1 - from MS
 objWinHttp.Open "GET", "http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18"
 objWinHttp.Send ' Send the request
 strHTML = objWinHttp.ResponseText
 ' strHTML will contain the timezone
 Set objWinHttp = Nothing ' Trash our object now that we're finished with it.
 %>

C
 /* You need to compile this with libcurl in order to work */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
  
 #include <curl/curl.h>
 #include <curl/types.h>
 #include <curl/easy.h>
 struct MemoryStruct {
         char *memory;
         size_t size;
 };
  
 static void *myrealloc(void *ptr, size_t size)
 {
         if(ptr)
                 return realloc(ptr, size);
         else
                 return malloc(size);
 }
  
 static size_t WriteMemoryCallback(void *ptr, size_t size, size_t nmemb, void *data)
 {
         size_t realsize = size * nmemb;
         struct MemoryStruct *mem = (struct MemoryStruct *)data;
  
         mem->memory = (char *)myrealloc(mem->memory, mem->size + realsize + 1);
         if (mem->memory) {
                 memcpy(&(mem->memory[mem->size]), ptr, realsize);
                 mem->size += realsize;
                 mem->memory[mem->size] = 0;
         }
         return realsize;
 }
  
 int main(int argc, char **argv)
 {
         CURL *curl_handle;
  
         struct MemoryStruct chunk;
  
         chunk.memory=NULL;
         chunk.size = 0;
  
         curl_global_init(CURL_GLOBAL_ALL);
  
         curl_handle = curl_easy_init();
         curl_easy_setopt(curl_handle, CURLOPT_URL,
                "http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18");
         curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
         curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
         curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
         curl_easy_perform(curl_handle);
         curl_easy_cleanup(curl_handle);
  
         /* Do something with chunk.memory */
  
         if(chunk.memory)
                 free(chunk.memory);
  
         return 0;
 }

Cold Fusion Markup Language
 <cfhttp url="http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18" method="get" timeout="30">
 <cfdump var="#cfhttp#">

Java / JSP
 StringBuffer buffer = new StringBuffer();
 String URL = "http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18";
 try {
         URLConnection connection = new URL(URL).openConnection();
         connection.setDoOutput(true);
         OutputStreamWriter writer = new OutputStreamWriter(connection.getOutputStream());
         writer.flush();
         BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
         String line = null;
         while ((line = reader.readLine()) != null) {
             buffer.append(line);
         }
         writer.close();
         reader.close();
 } catch (UnknownHostException e) {
         // unknown host
 } catch (IOException e) {
         // IO problem
 }
 String content = buffer.toString();

Perl
 use LWP::UserAgent;
 use HTTP::Response;
  
 my $content;
 my $ua = LWP::UserAgent->new();
 $ua->timeout(4);
 my $response = $ua->get("http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18");
 if($response->is_success()) {
         $content = $response->content();
 } else {
         $content = "";
 }
 # Do something with $content

Python
 from urllib import urlopen
 content = urlopen('http://www.timezoneauthority.com/tz.js?who=demo&ip=18.18.18.18').read()
 # Do something with content

Ruby
 require 'net/http'
 req = Net::HTTP.get_response(URI.parse('http://www.timezoneauthority.com/ws/tz.html?who=demo&ip=18.18.18.18'))
 content = req.body

© 2007 TimeZoneAuhority.com. All Rights Reserved. While using this site, you agree to have read and accepted our terms of use and privacy policy.