Search name region / city php

2

I'm using Yahoo's Weather API. The thing is, I want the time to be presented to the user's location.

Given that I am using the following:

$BASE_URL = "http://query.yahooapis.com/v1/public/yql";
$yql_query = 'select item from weather.forecast where woeid in (select woeid from geo.places(1) where text="Lisbon, pt")';

$yql_query_url = $BASE_URL . "?q=" . urlencode($yql_query) . "&format=json&u=c";

It works fine, but in this case it returns the time to Lisbon, pt (The location is defined in the query).

I want from php to fetch the user's location, but if it is by IP, it returns the location of the internet service, which means it is not where the user is actually. Is there another way to counter this? I've been able to fetch by javascript, but I can not use a javascript variable in PHP.

    
asked by anonymous 20.07.2016 / 11:25

1 answer

1

There is no automatic way to find out the user's precise location, other than by asking him;)

You can get the approximate location of the user through his or her IP address. You can use a service such as link to get location data over IP.

    
23.07.2016 / 18:35