Skip to content

C Geolation over IP-address (Colelction of service)

License

Notifications You must be signed in to change notification settings

wsjcpp/wsjcpp-geoip

Repository files navigation

wsjcpp-geoip

Build Status Github Stars Github Stars Github Forks Total alerts Language grade: C/C

C . Call request to another services for get location coordinates by IP-address

Integrate to your c project

include files:

src.wsjcpp/wsjcpp_core/wsjcpp_core.h
src.wsjcpp/wsjcpp_core/wsjcpp_core.cpp
src.wsjcpp/wsjcpp_core/wsjcpp_validators.h
src.wsjcpp/wsjcpp_core/wsjcpp_validators.cpp
src/wsjcpp_geoip.cpp
src/wsjcpp_geoip.h

or use a wsjcpp: wsjcpp install https://github.com/wsjcpp/wsjcpp-geoip:master

Example code usage:

WsjcppGeoIPResult res = WsjcppGeoIP::requestToIpApiCom("1.1.1.1");
if (res.hasError()) {
    std::cout << "FAILED: " << res.getErrorDescription() << std::endl;
} else {
    std::cout << "Service Name: " << res.getServiceName() << std::endl;
    std::cout << "IP Address: " << res.getIpAddress() << std::endl;
    std::cout << "Country: " << res.getCountry() << std::endl;
    std::cout << "Region Name: " << res.getRegionName() << std::endl;
    std::cout << "City: " << res.getCity() << std::endl;
    std::cout << "Latitude: " << res.getLatitude() << std::endl;
    std::cout << "Longitude: " << res.getLongitude() << std::endl;
}

Output:

Service Name: ip-api.com
IP Address: 1.1.1.1
Country: Australia
Region Name: New South Wales
City: Sydney
Latitude: -33.8688
Longitude: 151.209