Total members 11893 |It is currently Tue Nov 05, 2024 8:54 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





To retrieve the weather forecast for your location based only on your current IP, the full tutorial will have the following 5 sections (http://bit.ly/1A5Y651), that will:
- Describe elements needed for weather forecast retrieval
- Describe the weather station code field of IP2Location
- Show code that gets the weather station code from IP address
- Show code that retrieves the weather forecast from Yahoo! Weather using the weather station code.
- Show code that retrieves the weather forecast using IP2Location

Here, I will only show you how to retrieve the weather forecast.

Code:
//includes the IP2Location framework
require_once('IP2Location.php');

//function that sends and retrieves an answer from a HTTP request
function SendRequest( $url, $method = 'GET', $data = array(), $headers = array('Content-type: application/x-www-form-urlencoded') )
{
   $context = stream_context_create(array
   (
      'http' => array(
         'method' => $method,
         'header' => $headers,
         'content' => http_build_query( $data )
      )
   ));

   return file_get_contents($url, false, $context);
}

//the client's IP
$ip = $_SERVER['REMOTE_ADDR'];
// Standard lookup with no cache
$loc = new IP2Location('databases/db24.bin');


$stationCode=FindIPWeatherStationCode($ip,$loc);
GetWeatherForecastFromYahoo($stationCode);





Author:
Newbie
User avatar Posts: 4
Have thanks: 0 time

nice example !


_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : How to get the weather forecast using IP address
 what is MAC address     -  
 Get IP address code     -  
 Find MAC Address     -  
 change the MAC address     -  
 log visitor IP address.     -  
 Get Server address     -  
 validate email address in asp     -  
 Address Book in Java     -  
 ban visitor from a specific IP-address     -  
 Get address of the page from which the request was made     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com