Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pobing/sina_geoip
Retreive the geolocation of an IP address based on the http://int.dpool.sina.com.cn/iplookup/iplookup.php webservice
https://github.com/pobing/sina_geoip
Last synced: about 1 month ago
JSON representation
Retreive the geolocation of an IP address based on the http://int.dpool.sina.com.cn/iplookup/iplookup.php webservice
- Host: GitHub
- URL: https://github.com/pobing/sina_geoip
- Owner: pobing
- License: mit
- Created: 2013-07-02T08:14:07.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-03T03:23:21.000Z (over 11 years ago)
- Last Synced: 2024-10-09T16:45:41.955Z (about 1 month ago)
- Language: Ruby
- Size: 108 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# SinaGeoip
Retreive the geolocation of an IP address based on the [http://int.dpool.sina.com.cn/iplookup/iplookup.php](http://int.dpool.sina.com.cn/iplookup/iplookup.php) webservice.
## Installation
Add this line to your application's Gemfile:
gem 'sina_geoip'
And then execute:
$ bundle
Or install it yourself as:
$ gem install sina_geoip
## Usage
### Retrieve geolocation
SinaGeoIp.geolocation(ip_address)### Example
# 12.130.132.30 = sina.com.cn (CN)
GeoIp.geolocation('12.130.132.30')returns:
{
:ret => 1,
:start => "202.108.24.0",
:end => "202.108.58.255",
:country => "中国",
:province => "北京",
:city => "北京",
:district => "",
:isp => "联通",
:type => "",
:desc => ""
}### precision
There is an option to only retreive the country information and thus excluding the city details. This results in a faster response from the service since less queries need to be done.
#### precision country
GeoIp.geolocation('202.108.24.0', :precision => :country)
returns:
{
:country => "中国"
}#### precision province
GeoIp.geolocation('202.108.24.0', :precision => :province)
returns:
{
:country => "中国",
:province => "北京"
}#### precision city
GeoIp.geolocation('202.108.24.0', :precision => :city)
returns:
{
:country => "中国",
:province => "北京",
:city => "北京"}
## Test
rspec spec/sina_geoip/sina_geoip_spec.rb
## Contributors
* [geo_ip](https://github.com/jeroenj/geo_ip)
## Bugs
Please report them on the [Github issue tracker](https://github.com/pobing/sina_geoip/issues)
for this project.If you have a bug to report, please include the following information:
* **Version information for bierdopje, Rails and Ruby.**
* Stack trace and error message.You may also fork this project on Github and create a pull request.
Do not forget to include tests.## Copyright
Copyright (c) 2013 by pobing.