Ahmad Masykur

Share your knowledge although one function!

About the author

Ahmad Masykur is a Software Architecture Engineer at PT. Freeport Indonesia Jakarta Indonesia.
In this blog, I share things of interest to me. Most topics are likely to be related to software development, but don't hold me to it.



Powered by

Widget Prayer Time not found.

There is an error in XML document (4, 16278).X

Page List


Ahmad Masykur

Updating Prayer Widget due to Previous IP to Geo Service was Unavailable

I was developed Prayer Time widget a month ago. I was used IP to geo service that not available anymore. This update using hostip.info service instead. The hostip.info service is not reliable enough for all IP world wide. Some IPs are not covered yet but more stable than previous service.

Here’s core of my code to retrieve geographic information from hostip.info.

WebClient webClient = new WebClient();
string responseString = null;
    responseString =
catch (WebException)
    responseString = string.Empty;
catch (Exception)
    responseString = string.Empty;
Regex regex = new Regex("Country\\:\\s(?<Country>[A-Za-z0-9]+)\\s\\((?<CountryId>[A-Z]{2})\\)\\nCity\\:\\s(?<City>[A-Za-z0-9]+)\\nLatitude\\:\\s(?<Latitude>\\-?[0-9\\.]+)\\nLongitude\\:\\s(?<Longitude>\\-?[A-Za-z0-9\\.]+)");
if (!string.IsNullOrEmpty(responseString))
    Match m = regex.Match(responseString);
    if (m.Success)
        city = m.Groups["City"].Value;
        country = m.Groups["Country"].Value;
        countryId = m.Groups["CountryId"].Value;
        longitude = m.Groups["Longitude"].Value;
        latitude = m.Groups["Latitude"].Value;

The complate source code can be downloaded here.

I hope this update will be more reliable that previous version.

Categories: BlogEngine
Permalink | Comments (3) | Post RSSRSS comment feed


Forsikring United States | Reply

Friday, February 06, 2009 6:54 PM


The concept was simple but brilliant: place a GPS device in a briefcase and mail it via DHL with precise travel instructions over the course of a 55 day period. When all was said and done, the GPS data formed a virtual self-portrait of the artist that spread over 6 continents and 62 countries covering nearly 70,000 miles.

On Site Computer Service United States | Reply

Saturday, February 07, 2009 7:10 PM

On Site Computer Service

Onsite Computer Service is a term for any of activity related to Computer Service site for the World Wide Web or the intranet. Actually this includes static websites to dynamic website development.

internet marketing indonesia Indonesia | Reply

Monday, February 09, 2009 4:34 PM

internet marketing indonesia

prayer itu untuk apa ya mas? saya baru dengar

Add comment

  Country flag

  • Comment
  • Preview