• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

Using ASP, how can I code weather for my site?

I have an ASP project that I want to add current temperature (Fahrenheit) and current conditions (cloudy, sunny, rain, etc.) to my Web site. I know there are a lot of weather widgets available by google search, but I am looking for ASP code that will allow me to display this information in a small place. The NOAA weather code I am interested in is KTDZ.

With the help of and Experts Exchange expert, I have the code for PHP. But the server for my Web site is ASP.
Any suggestions on how to do this? I have attached the PHP code for what I am looking (I can find a converter that works correctly;.)
<?php // RAY_temp_kfranck.php
error_reporting(E_ALL);


// DEMONSTRATE A WEATHER WIDGET USING IGOOGLE API


date_default_timezone_set('America/New_York');
$url = 'http://www.google.com/ig/api?weather=toledo,oh';
$xml = file_get_contents($url);
$obj = SimpleXML_Load_String($xml);

// ACTIVATE THIS TO SEE THE OBJECT
// echo "<pre>";
// var_dump($obj);
// echo "</pre>";

// EXTRACT AND FORMAT THE DATA
$c = $obj->weather->forecast_information->city["data"];
$d = $obj->weather->forecast_information->current_date_time["data"];
$d = date('g:ia', strtotime($d));
$s = $obj->weather->current_conditions->condition["data"];
$f = $obj->weather->current_conditions->temp_f["data"];

// THE FINISHED HTML TAG WE WANT
$w = "<span id=\"weather\">$s and $f&#176; at $d in $c</span>" . PHP_EOL; 


// THE HTML STRING IN HEREDOC NOTATION
$html = <<<ENDHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 1</title>
</head>
<body>
$w
</body>
</html>
ENDHTML;

// WRITE THE STRING TO THE BROWSER
echo $html;

Open in new window

0
kfranck
Asked:
kfranck
1 Solution
 
kevp75Commented:
This should get you going:
http://www.codeproject.com/KB/asp/googleapisinasp.aspx

it's just an XML file, so really all you need to to is pass in your URL, and parse the resulting XML return
0
 
kfranckAuthor Commented:
Good suggestion. Thanks.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now