Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8443677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:12:08+00:00 2026-06-10T09:12:08+00:00

I am using a code that changes my wordpress website’s background according to the

  • 0

I am using a code that changes my wordpress website’s background according to the Yahoo API URL I inserted. Is there anyway to make it automatically show the Visitors weather without any databases? I have though of using Google’s API but I am a novice in programming and dont know how to implement it into my website. Please help!
The code can be viewed here: http://css-tricks.com/using-weather-data-to-change-your-websites-apperance-through-php-and-css/

Please be thorough because I am new to PHP
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:12:09+00:00Added an answer on June 10, 2026 at 9:12 am

    This will get a user’s zip code from their IP address using the open-source IP2Coordinates service from the Data Science Toolkit.

    There are more accurate Geo-location APIs out there, but this one is absolutely free and dead simple to use. If I were developing this on a production site, I’d use HTML5 Geolocation as my primary method with a fallback to a better IP geolocator, like Max Mind.

    Note that this will only work for US users of your site. You should probably pass more detailed data to one of the other Yahoo place APIs to get one of their WOEIDs to use (or pick a different weather API).

    Here is the code for you. Put this right after the <?php tag in your sample code. Once you’re sure it’s working, comment out all the lines that begin with print.

    //Get the user's IP address
    $user_ip = $_SERVER['REMOTE_ADDR'];
    //The Data Science Toolkit URL
    $url = 'http://www.datasciencetoolkit.org/ip2coordinates/';
    //Find the user's location from their IP. 
    //*** You need the get_data function from the sample code
    $raw_geocode = json_decode( get_data( $url . $user_ip) );
    //Check if the user is in the US
    if ('US' === $raw_geocode->$user_ip->country_code) {
      //If yes, store their zip code in a variable, and print it
      $zip_code = $raw_geocode->$user_ip->postal_code;
      printf('<p>Your zip code is: %s</p>', $raw_geocode->$user_ip->postal_code);
    } else {
      //If the user isn't in the US, set a sip code that will work.
      $zip_code = '97211';
      //and print an error
      printf('<p>Sorry, this app does not work in %s.</p>', $raw_geocode->$user_ip->country_name);
    }
    
    //Print the raw data for debugging.
    printf('<pre>%s</pre>', print_r($raw_geocode, true));
    

    Now change the line in the sample code that begins with $data = to this:

    $data = get_data("http://weather.yahooapis.com/forecastrss?p={$zip_code}&u=f");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using .net. Is there some code somewhere that can change $11,456.50 -> eleven
I have code that changes the color of navigation bar using appearance attribute. I
I'm using a code that looks like that: img.load(function(){ // do some stuff $(this).width();
i'm using that code for encrypt a string with 3DES in IOS and i
I am using code in Matlab that writes xy coordinates and an associated z-value
I am using a Java code that I found that generates a public and
I have some code using Lucene that leaves the default conjunction operator as OR,
I have some code that is using SyncEnumerator. As you can see here ,
Below is the code that I'm using in ms access to list the data
This is the code that I'm using to generate a DH keypair: KeyPairGenerator keyGen

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.