Searching for IP 54.73.154.147 using latest GeoLite2 IP database I get the following results:
Seattle, US, United States
But the IP address is actually from a AWS server spun up in Ireland. If I submit the same IP to the GeoIP Precision test page (https://www.maxmind.com/en/geoip-demo) I get the correct results:
Dublin, IE, Ireland
Can anyone think of a reason as to why Im getting such erroneous results?
The reason that you are getting two different results is because they simply are different versions of databases and the one you search on their web interface is apparently more accurate and more up-to-date. GeoLite2 is not very accurate and you need to update it every week to receive accurate information since IP addresses are changing every minute. For example I purchased a few IP addresses and I can use one today and shift to another one tomorrow as I please. Bigger companies do that more often and most of these IP addresses can go from one country to another.
And if you just want to stick with MaxMind product you can use this url to request the json:
https://www.maxmind.com/geoip/v2.1/city/{{ip.address}}?use-downloadable-db=1&demo=1
Note that only 25 requests are allow a day in theory (but easily hackable). Don't ask me how to hack it because it is against the rules of Stackoverflow.
As #michael pointed out, you can't do anything if geolite's database is wrong.
Here is antoher alternative: userinfo.io. It's actually a merge of several databases so it can be more accurate.
I tested it with your IP and it returns the right location.
{
"ip_address": "54.73.154.147",
"position": {
"latitude": 53.3331,
"longitude": -6.2489
},
"continent": {
"name": "Europe",
"code": "EU"
},
"country": {
"name": "Ireland",
"code": "IE"
},
"city": {
"name": "Dublin"
}
}
You can currently use the javascript wrapper or the java wrapper.
I had exactly the same problem. My EC2 server is in Ireland, but geoip shows US.
I switched to freegeoip.net, which seems accurate for this case.
An example of usage in PHP:
$json_data = file_get_contents("http://freegeoip.net/json/" . $hostname);
return json_decode($json_data, TRUE);
This Script will solve your issue .
i had tested it with your ip address and it is giving correct result
<?php
/*Get user ip address*/
//$ip_address=$_SERVER['REMOTE_ADDR'];
$ip_address="54.73.154.147";
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];
/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];
$latitude = $addrDetailsArr['geoplugin_latitude'];
$logitude = $addrDetailsArr['geoplugin_longitude'];
/*Comment out these line to see all the posible details*/
/*echo '<pre>';
print_r($addrDetailsArr);
die();*/
if(!$city){
$city='Not Define';
}if(!$country){
$country='Not Define';
}
echo '<strong>IP Address</strong>:- '.$ip_address.'<br/>';
echo '<strong>City</strong>:- '.$city.'<br/>';
echo '<strong>Country</strong>:- '.$country.'<br/>';
echo '<strong>Latitude</strong>:- '.$latitude.'<br/>';
echo '<strong>Longitude</strong>:- '.$logitude.'<br/>';
?>
Related
If an Office 365 contact's email address is invalid (ex: user#example?com), how do I retrieve the the email address with Microsoft Graph?
I've tried /contacts and /contacts/{id}. The first returns an empty address:
"emailAddresses": [
{
"name": "name",
"address": ""
}
]
and the second simply omits it:
"emailAddresses": [
{
"name": "name"
}
]
Edit: By "contact" I mean Outlook contacts accessible in the Office 365 People app, not regular Office 365 users. Sorry if my question was unclear.
I'm not sure if this would work, but perhaps give it a try.
string email = await graphClient.Users[your_users_id].Request().Select("Mail").GetAsync().Mail;
To get the answer above, I used this Get User documentation which briefly talks about Select statements. And this documentation has a list of the properties which are available to the Select statement.
Found an issue on Github that solved my problem.
Turns out an Exchange contact's (first) EmailAddress has an hidden PidLidEmail1OriginalDisplayName in addition to its address.
When you set the email address to an invalid one, the invalid address is stored in the OriginalDisplayName and its address is cleared, which is the reason the contact's email address is (Empty) in Office 365 People's contact list but the invalid address seems to still be there when you edit the contact.
PidLidEmail1OriginalDisplayName is an MAPI property. In order to obtain it, we need to use extended properties. The request should look like below but with the spaces URL-encoded to %20:
GET /me/contacts/{id}?$expand=singleValueExtendedProperties($filter=id eq 'String {00062004-0000-0000-C000-000000000046} Id 0x8084')
The response should include an additional field containing the invalid address:
"singleValueExtendedProperties": [
{
"id": "String {00062004-0000-0000-c000-000000000046} Id 0x8084",
"value": "user#example?com"
}
If the contact has multiple email addresses, use PidLidEmail2OriginalDisplayName/PidLidEmail3OriginalDisplayName for the contact's second or third email address.
I am getting an empty result from yahoo finance when i use the api to table yahoo.finance.quotes
I used your query to check the interface and the result is NULL. Apparently there is a malfunction.
steps for testing:
go to https://developer.yahoo.com/yql/console/
show community tables
Mark checkbox: show community tables
uncheck: DIAGNOSTICS
Select a table: finance.quotes
A default query will appear
select * from yahoo.finance.quotes where symbol in ("YHOO","AAPL","GOOG","MSFT")
The result
{
"query": {
"count": 0,
"created": "2017-11-02T13:21:01Z",
"lang": "en-US",
"results": null
}
}
Very sadly and quite outrageously Yahoo decided to stop this service without any warning.
See admin message here
So many services depend on it, it's like Google saying they would suddenly stop their maps API... At this point I am blocking yahoo in our DNS so no one in our company will ever use Yahoo again since they are not a reliable entity.
I have created a web application from which I am trying to get recommendations of a user from his/her LinkedIn Profile using URL
String url="https://api.linkedin.com/v1/people/~:(recommendations-received:(id,recommendation-type,recommendation-text,recommender))?format=json"
When I am using this URL in the
Api Explorer it works fine. And gives output:-
{ "recommendationsReceived": {
"_total": 2,
"values": [
{
"id": 558598601,
"recommendationText": "xxx is among the best team players I ever worked with. He has handled client effectively with smooth operations. I had always seen him as person with solution mindset and always look for solution rather than thinking about the problem. ",
"recommendationType": {
"code": "colleague"
},
"recommender": {
"firstName": "XXX",
"id": "YYYY",
"lastName": "XXX"
}
},
{
"id": ZZZZ,
"recommendationText": "XXX is one of the most dedicated person at work.I always him with a flexible attitude and ready to adapt himself in all situation.I have seen him work all night to catch up all the deadlines and deliver on time ."
"recommendationType": {
"code": "colleague"
},
"recommender": {
"firstName": "XXX",
"id": "YYYY",
"lastName": "XXXX"
}
}
] } }
The problem comes, when I am using this URL in my Developer app.It doesn't give any error just simple return an empty map [:] as output in response
Irrespective of these recommendation fields, I successfully get the user basic profile data such as email, id, image,firstName,lastName.Means my code is working for other fields well but not for these recommendation fields*
To find the solution, I did some internet surfing and find a link of Linked API docs
Linked API Docs
As per Docs following selection of profile fields are only available
to applications that have applied and been approved for the Apply with
LinkedIn program:
Recommendation Fields
I already created a LinkedIn Developer account to get key & Secret
So how do I apply and get approval for Apply with LinkedIn Recommendation Fields.
I already have seen the LinkedIn support but can't find the way to ask question to the Linked Developer help support
Please suggest me the right way.
After a long internet surfing,I have found something fruitful that, I have to fill up a form to get these fields.Here is the form
along with its procedural details
You can use just recommendations-received keyword. Try the following link. I am getting all recommendations details with this link.
https://api.linkedin.com/v1/people/~:(recommendations-received)?format=json
I know I can get user's IP address like this:
remote_ip = request.remote_ip
Now I was wondering how can I find out user's country and city from his IP address? I've found this buy it is only for country:
http://api.hostip.info/country.php
City can be found like this:
http://api.hostip.info
The problem is it is not showing the city correctly. I am currently in one of the biggest cities in the world and it says it is an unknown city.
What would be the best way to find out user's country and city from his IP address? I am looking for a free solution or at least something really cheap.
Thank you :)
You could try geocoder gem to obtain location by ip address:
Geocoder.search('5.18.186.107').first.city # => "Saint Petersburg"
Geocoder.search('213.180.204.26').first.country # => "Turkey"
Or even use built-in functionality w/o transitional actions:
# somewhere in your action
result = request.location # returns Geocoder::Result object
By default it uses http://freegeoip.net/ service for IP resolving, so in case you do not want to use any additional gems you can communicate with it using REST API.
You could try my API, https://ipinfo.io. It returns JSON by default, with a bunch of different fields:
$ curl ipinfo.io
{
"ip": "24.6.61.239",
"hostname": "c-24-6-61-239.hsd1.ca.comcast.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.3845,-122.0881",
"org": "AS7922 Comcast Cable Communications, LLC",
"postal": "94040"
}
It's free for up to 1000 requests per day. See https://ipinfo.io/developers for more details.
You can run a WHOIS with the IP address. I'm not sure if this can be done with code but if you want to do it only for a few IP's then sites like http://www.tools.whois.net/whoisbyip/ can provide information including city location. I believe different sites offer different depths of information.
One more solution is to use ruby gem for Yandex locator (https://tech.yandex.ru/locator/). Yandex locator is a service that finds mobile devices in a region delineated by a circle. The service returns longitude, latitude and precision. https://github.com/sergey-chechaev/yandex_locator
client = YandexLocator::Client.new(api_key: 'api key', version: '1.0')
result = client.lookup(ip: { address_v4: '178.247.233.3' })
result.position
# => {"altitude"=>0.0, "altitude_precision"=>30.0, "latitude"=>41.00892639160156, "longitude"=>28.96711158752441, "precision"=>100000.0, "type"=>"ip"}
I have a list of ip addresses many of which will be from a university network. What is the best way to find out which universities are in this list?
You could use http://ipinfo.io (a service I built) for this. Here's some example output from the API:
$ curl ipinfo.io/128.32.0.1
{
"ip": "128.32.0.1",
"hostname": "No Hostname",
"city": "Berkeley",
"region": "California",
"country": "US",
"loc": "37.8668,-122.2536",
"org": "AS25 University of California at Berkeley",
"postal": "94720"
}
Notice the org field, "AS25 University of California at Berkeley". You can get just those details by appending /org to the URL:
$ curl ipinfo.io/128.32.0.1/org
AS25 University of California at Berkeley
You can do a bulk lookup of your IP addresses by putting them in a file and running the following command:
$ cat ips.txt | xargs -I% curl -s http://ipinfo.io/%/org | paste ips.txt -
128.32.0.1 AS25 University of California at Berkeley
128.62.76.244 AS18 University of Texas at Austin
24.32.142.2 AS7018 AT&T Services, Inc.
171.64.84.194 AS32 Stanford University
18.9.44.47 AS3 Massachusetts Institute of Technology
67.188.232.130 AS7922 Comcast Cable Communications, Inc.
You can find out more details about the API at http://ipinfo.io/developers.
Universities and colleges used to be their own Internet Service Provider (ISP) and you should be able to get these universities.
I played with a world uinversity names database collected from LinkedIn and Webometric and with an old IP-ISP database I had under my hand (dating from 2012) to get a list of about 5800 universities / colleges.
The list is probably not exhaustive because the name of the IP-ISP database may differs from the university names database and because the IP-ISP database could be a bit outdated.
But, it should be a good start if you don't want to use any API.
Then, you should be able to do something similar to:
SELECT * FROM `isp_universities`
WHERE INET_ATON('192.16.181.4')
BETWEEN from_dec AND to_dec
to obtain:
192.16.181.0 to 192.16.181.255
Massachusetts Institute of Technology
http://www.mit.edu/
Take a look here, I pushed the database on Bitbucket.