BigBrotherBot/big-brother-bot

IP Api is not accessible from my country (Geolocation Plugin)

shahriar-shojib opened this issue · 0 comments

Hello,
I am trying to use a different ip location api:
http://ipinfo.io/%s/json

However, it is not working.
Here is my code:
`class IpApiGeolocator(Geolocator):

_url = 'http://ipinfo.io/%s/json'

def getLocation(self, data):
    """
    Retrieve location data
    :param data: A B3 client object or an IP string
    :raise GeolocalizationError: When we are not able to retrieve location information
    :return: A Location object initialized with location data
    """
    ip = self._getIp(data)
    rt = requests.get(self._url % ip, timeout=self._timeout).json()

    if rt['status'] == 'fail':
        raise GeolocalizationError('invalid data returned by the api: %r' % rt)

    return Location(country=rt.get('country', None), region=rt.get('region', None), city=rt.get('city', None), rc=rt.get('region', None), isp=rt.get('org', None),
                    lat=rt.get('loc', None), lon=rt.get('loc', None))

`