Find Weather Forecast from IP Address PHP Script


Find Weather Forecast from IP Address PHP Script

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.

 

 
 
  1. //includes the IP2Location framework
  2. require_once('IP2Location.php');
  3. //function that sends and retrieves an answer from a HTTP request
  4. function SendRequest( $url, $method = 'GET', $data = array(), $headers = array('Content-type: application/x-www-form-urlencoded') )
  5. {
  6.       $context = stream_context_create(array
  7.       (
  8.             'http' => array(
  9.                   'method' => $method,
  10.                   'header' => $headers,
  11.                   'content' => http_build_query( $data )
  12.             )
  13.       ));
  14.       return file_get_contents($url, false, $context);
  15. }
  16. //the client's IP
  17. $ip = $_SERVER['REMOTE_ADDR'];
  18. // Standard lookup with no cache
  19. $loc = new IP2Location('databases/db24.bin');
  20. $stationCode=FindIPWeatherStationCode($ip,$loc);
  21. GetWeatherForecastFromYahoo($stationCode);

 

 


Related Post


Facebook Campaigner v2.1 – Facebook Autoposter P... Facebook Campaigner v2.1 – Facebook AutoposterFacebook Campaigner v2.1 – Facebook Autoposter Facebook campaigner is a simple and user friendly ...
The Bug Genie Project Management PHP Script Free D... The Bug Genie Project Management PHP Script Free Download   The Bug Genie Friendly issue tracking and project management. Issue tracking and ...
Ionic Mobile App Builder v18.12.10 PHP Script Dow... Ionic Mobile App Builder v18.12.10 - nulled Mobile App Download Ionic Mobile App (IMA) Builder is a web tool (not SaaS) to build a template code fo...
Read and Write File PHP Script Read and Write File PHP Script This php code is used to read and write file. This code is also used for web hosting project to manipulation file...
SiteSpy v3.1 – Complete Visitor & SEO A... SiteSpy v3.1 - Complete Visitor & SEO AnalyticsSiteSpy v3.1 - Complete Visitor & SEO Analytics Complete visitor and SEO anlytics package in...

Read Me

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

"